[PATCH] posix: Fix improper assert in Linux posix_spawn (BZ#22273)

Florian Weimer fweimer@redhat.com
Wed Oct 18 14:12:00 GMT 2017


On 10/18/2017 01:51 PM, Adhemerval Zanella wrote:
> +	/* There still an unlikely case where the child is cancelled after
> +	   setting args.to a positive error value.  Also due a possible
> +	   pid reuse race (where the kernel allocated the same pid to
> +	   unrelated process) we need not to undefinitely hang expecting
> +	   an invalid pid.  In both cases an error is returned to the
> +	   caller.  */
> +	__waitpid (new_pid, NULL, WNOHANG);

It took a while to wrap my head around this one.  I don't think the 
WNOHANG makes much of a difference because in the non-race case, the 
kernel should ensure that the wait notification is ready before vfork 
returns from the kernel in the parent process.  We had some issues with 
wait notifications, but I hope this one is actually properly serialized.

The race case (i.e., PID reuse because a signal handler or another 
thread does a wildcard waitpid) is vaguely undefined anyway.

We could probably do better if we called clone without SIGCHLD.  Not 
sure if that works, but it's a different enhancement and out of scope 
for this patch.  If Andreas is happy with what you've got, so am I.

Thanks,
Florian



More information about the Libc-alpha mailing list