posix/tst-waitid.c possible race condition on Linux
Rich Felker
dalias@aerifal.cx
Thu Jun 13 00:10:00 GMT 2013
On Wed, Jun 12, 2013 at 05:03:30PM -0700, Roland McGrath wrote:
> I think the test was racy. A change that will probably fix it is on the
> branch roland/tst-waitid and the patch is below, but I haven't been able to
> test it yet.
> [...]
> +
> + /* Give the child a chance to stop. The waitpid call below will block
> + until it has stopped, but if we are real quick and enter the waitpid
> + system call before the SIGCHLD has been generated, then it will be
> + discarded and never delivered. */
> + sleep (3);
> +
> pid_t wpid = waitpid (pid, &fail, WUNTRACED);
Wouldn't it make more sense to use sigtimedwait or sigwaitinfo to get
the signal? This would avoid the race condition without adding a long
sleep.
Rich
More information about the Libc-alpha
mailing list