This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] posix: Do not use WNOHANG in waitpid call for Linux posix_spawn


On 10/23/2017 11:38 AM, Szabolcs Nagy wrote:

> VFORK is not precise (i think under ptrace parent can
> continue before child execs) 

It can not, modulo ancient kernel bugs, perhaps.  Even if the
ptracer PTRACE_CONTs the parent, the parent remains frozen
in "D (disk sleep)" until the child execs or dies, at which
point the ptracer is notified with a PTRACE_EVENT_VFORK_DONE
event, if enabled with PTRACE_O_TRACEVFORKDONE.

(GDB has to be careful to avoid resuming a vfork parent if not
resuming the child, otherwise the whole debug session deadlocks,
and Ctrl-C won't unblock it (because the parent/child's process
group would be made the foreground process group on resumption
and that's where the kernel would be sending the SIGINT.  Since
the parent nor the child are scheduled, the SIGINT remains
pending forever.)

Now, if a multi-threaded program vforks, then all other
non-parent threads in the parent continue running.  Only
the thread that vforked is frozen.  But you're likely already
considering that undefined behavior.

> so using close-on-exec fd is a better way to sync with exec.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]