Download raw body.
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);