[PATCH][BZ #14782] Do not enable asynchronous cancelation in system
Ondřej Bílka
neleai@seznam.cz
Tue Jan 14 14:41:00 GMT 2014
On Tue, Jan 14, 2014 at 08:42:49AM -0500, Carlos O'Donell wrote:
> On 01/14/2014 07:43 AM, OndÅej BÃlka wrote:
> >> This looks good go me... however!
> >>
> >> OK to commit as long as you prove waitpid is actually a
> >> cancellation point as required by POSIX.
> >>
> >
> > It in list here:
> >
> > http://pubs.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_09.html#tag_02_09_05_02
>
> My apologies. I wasn't clear enough on the requirement.
>
> I want you to look at the glibc waitpid implementation
> and prove it actually has a cancellation point.
>
It does, linux waitpid implementation follows same pattern as system:
_pid_t
__libc_waitpid (__pid_t pid, int *stat_loc, int options)
{
if (SINGLE_THREAD_P)
{
#ifdef __NR_waitpid
return INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options);
#else
return INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL);
#endif
}
int oldtype = LIBC_CANCEL_ASYNC ();
#ifdef __NR_waitpid
int result = INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options);
#else
int result = INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL);
#endif
LIBC_CANCEL_RESET (oldtype);
return result;
}
Also a pattern here is wrong as it duplicates code. These should be
rewritten to:
_pid_t
__libc_waitpid (__pid_t pid, int *stat_loc, int options)
{
int oldtype;
if (!SINGLE_THREAD_P)
oldtype = LIBC_CANCEL_ASYNC ();
#ifdef __NR_waitpid
int result = INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options);
#else
int result = INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL);
#endif
if (!SINGLE_THREAD_P)
LIBC_CANCEL_RESET (oldtype);
return result;
}
More information about the Libc-alpha
mailing list