Reading the kernel sources, I was sure we'd get an ECHILD if the child
hadn't exited yet, but that's not the case. We only get ECHILD if the
current process has no child processes. But if we do have one and the
one we're waiting for hasn't exited, waitid() returns 0.
So let's not attempt to correct it with forkfd_wait() or forkfd_wait4().
Those have "wait" in the name, so they should behave exactly the same
way. The man pages say:
waitpid(): if WNOHANG was specified and one or more child(ren)
specified by pid exist, but have not yet changed state, then 0 is
returned.
waitid(): returns 0 on success or if WNOHANG was specified and no
child(ren) specified by id has yet changed state
This was found while studying QTBUG-100174.
QProcess does not use this code path (blocking mode forkfd only).
Matching OpenDCDiag PR:
https://github.com/opendcdiag/opendcdiag/pull/62
Pick-to: 6.2 6.3
Change-Id: Ibf4acec0f166495998f7fffd16d6de6853a6e5a8
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>