From: Arran Cudbard-Bell Date: Wed, 15 Sep 2021 05:03:16 +0000 (-0500) Subject: Fix spurious error X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c56c0a9e1fa3d56ebf51478eaf48ccce0572985;p=thirdparty%2Ffreeradius-server.git Fix spurious error --- diff --git a/src/lib/util/event.c b/src/lib/util/event.c index 7b09ac1b865..2844ee77571 100644 --- a/src/lib/util/event.c +++ b/src/lib/util/event.c @@ -1685,8 +1685,15 @@ int _fr_event_pid_wait(NDEBUG_LOCATION_ARGS * * We don't reap the process here to emulate * what kqueue does (notify but not reap). + * + * waitid returns >0 on success, 0 if the + * process is still running, and -1 on failure. + * + * If we get a 0, then that's extremely strange + * as adding the kevent failed for a reason + * other than the process already having exited. */ - if (waitid(P_PID, pid, &info, WEXITED | WNOHANG | WNOWAIT) < 0) { + if (waitid(P_PID, pid, &info, WEXITED | WNOHANG | WNOWAIT) > 0) { switch (info.si_code) { case CLD_EXITED: case CLD_KILLED: