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: posix/tst-waitid.c possible race condition on Linux


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


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