From: Stefan Sperling Subject: Re: responsive watch wip To: Ted Unangst Cc: tech@openbsd.org Date: Wed, 11 Jun 2025 10:15:47 +0200 On Mon, Jun 09, 2025 at 11:28:35PM -0400, Ted Unangst wrote: > We might lose track of which child exited? Not sure how much this > matters. This is where I would use kevent, because I don't know how > to get the exiting pid out of libevent. It is possible to register signal handlers via libevent. Such signals will appear as EV_SIGNAL events in the event loop. If you catch SIGCHLD this way then you can get the pid from waitpid(). For example, exiting children in gotd are caught like this: void gotd_sighdlr(int sig, short event, void *arg) { [...] switch (sig) { [...] case SIGCHLD: for (;;) { pid = waitpid(WAIT_ANY, &status, WNOHANG); [...] int main(int argc, char **argv) { struct event evsigchld; [...] signal_set(&evsigchld, SIGCHLD, gotd_sighdlr, NULL); signal_add(&evsigchld, NULL);