Opened 5 years ago

#13139 new Bugs

child::join() incorrectly throws `waitpid(2) failed: No child processes` if child exited abnormally

Reported by: keithb@… Owned by:
Milestone: To Be Determined Component: process
Version: Boost 1.64.0 Severity: Problem
Keywords: Cc:

Description

Create a child process. Let it die abnormally (for example, calling kill(getpid(), SIGABRT) in the child). In the parent, call child.join().

It appears that the ::waitpid loop in boost::process::detail::posix::wait at github.com/boostorg/process/blob/boost-1.64.0/include/boost/process/detail/posix/wait_for_exit.hpp#L26-L31 only checks that the child ended because of a call to ::exit() and does not check for exiting via signal (WIFSIGNALED()).

Because WIFSIGNALED() is true, WIFEXITED() is false; and because it's false, the loop will continue and call ::waitpid() again... this time with a child PID to a process which has already been reaped. waitpid() will report an error (indicating that there's no such child prcess), and the error will be thrown.

The child's exact reason for exiting is lost, which is why I believe this should be marked a "Showstopper" severity; a workaround would be to avoid calling boost::process::wait() in any fashion and to instead use a custom waitpid loop using the child.native_handle().

Attachments (2)

killer.c (465 bytes ) - added by keithb@… 5 years ago.
killer.c: a simple C app that sends a specified signal number to itself
killer-test.cpp (687 bytes ) - added by keithb@… 5 years ago.
killer-test.cpp: small application that uses boost::process library to exercise the killer app which would be produced by killer.c

Download all attachments as: .zip

Change History (2)

by keithb@…, 5 years ago

Attachment: killer.c added

killer.c: a simple C app that sends a specified signal number to itself

by keithb@…, 5 years ago

Attachment: killer-test.cpp added

killer-test.cpp: small application that uses boost::process library to exercise the killer app which would be produced by killer.c

Note: See TracTickets for help on using tickets.