watchDogDaemon (kernel.cpp)
- Client lines are assembled in a buffer. readLine() on the non-blocking
socket dropped the bytes of a line that had only partly arrived.
- EOF (client closed or crashed without "-1") ends the monitoring of that
client. Before, EOF read as "no data", and after the deadline kill(9) went
to a PID that may belong to another process by then.
- The handler record is zeroed. "finished" was uninitialized (malloc), so
the accept loop could pthread_join() a live handler and block.
- Finished handlers are joined, freed and erased correctly. erase()
inside the for loop skipped the next one, and the records were never
freed. A record whose thread could not be created is freed.
pthread_create() returns an error number, not -1.
- The bind() result is checked.
- The log says which PID is watched or stopped, and for a stall how long
ago the last update was ("WD update STALLED! (PID n, last update N ms
ago)").
kernelPrototype
- Sends getpid() as the PID to kill (was gettid(): the same value only in
the main thread).
Tested with the rebuilt daemon: the kernel scenarios as before (normal,
6 s step: not killed; hang: killed). A client that closes without "-1":
its process isn't killed later. An update split into 3 pieces, 6 times
with a 4 s deadline: understood, not killed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16