This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #14782] Do not enable asynchronous cancelation in system
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Carlos O'Donell <carlos at redhat dot com>
- Cc: Rich Felker <dalias at aerifal dot cx>, libc-alpha at sourceware dot org
- Date: Tue, 14 Jan 2014 15:41:31 +0100
- Subject: Re: [PATCH][BZ #14782] Do not enable asynchronous cancelation in system
- Authentication-results: sourceware.org; auth=none
- References: <20140112121310 dot GA28961 at domone dot podge> <20140112152839 dot GY24286 at brightrain dot aerifal dot cx> <52D2D2F7 dot 8080301 at redhat dot com> <20140114124328 dot GB15164 at domone dot podge> <52D53ED9 dot 9050307 at redhat dot com>
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;
}