This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Remove signal handling for nanosleep (bug 16364)
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org, Adhemerval Zanella <adhemerval dot zanella at linaro dot com>
- Date: Tue, 10 Nov 2015 11:29:26 -0200
- Subject: Re: [PATCH v2] Remove signal handling for nanosleep (bug 16364)
- Authentication-results: sourceware.org; auth=none
- References: <1447160038-11754-1-git-send-email-adhemerval dot zanella at linaro dot org> <mvmy4e6yoxv dot fsf at hawking dot suse dot de>
On 10-11-2015 11:16, Andreas Schwab wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>
>> +/* Fork and terminate the child in 0.25s while parent waits on a nanosleep
>> + for 0.5s. */
>> +static int
>> +check_nanosleep_base (void)
>> +{
>> + int ret = 0;
>> + pid_t f = fork ();
>> + if (f == 0)
>> + {
>> + // child
>> + struct timespec tv = { .tv_sec = 0, .tv_nsec = 250000000UL };
>> + nanosleep (&tv, &tv);
>> + _exit (EXIT_SUCCESS);
>> + }
>> + else if (f > 0)
>> + {
>> + // parent
>> + struct timespec tv = { .tv_sec = 0, .tv_nsec = 500000000UL };
>> + ret = nanosleep (&tv, &tv);
>> + }
>> + else if (f == -1)
>> + {
>> + puts ("error: fork failed");
>> + _exit (EXIT_FAILURE);
>> + }
>> + return ret;
>> +}
>
> You should wait for the child before returning.
> How do you avoid the race between the parent and the child?
>
That's the hole points of the previous discussion in v1 patch while
Florian also pointed this racy. He neither I could devise a race-free
testcase to check for this issue so my questioning was if someone have
a way to remove the race or if we really should push for this test.
> Andreas.
>