sigwait() cancellation point
David Xu
davidxu at freebsd.org
Tue Sep 7 07:06:07 UTC 2010
Jilles Tjoelker wrote:
> Our sigwait() implementation may not be POSIX-compliant as it returns
> EINTR when it is interrupted by a caught signal. (Unfortunately I can
> only find this in SUSv4 in the Rationale, B.2.3 Error Numbers,
> Disallowing Return of the [EINTR] Error Code; the sigwait() page in XSH
> does not list an [EINTR] error condition, but does not prohibit one
> either like pthread_mutex_lock() and various others do.)
>
> However, libthr's wrapper for sigwait() relies on EINTR. To keep
> the possibility of changing this to be what POSIX intends, it would be
> nice to remove this dependency.
>
> One way is to include SIGCANCEL in the set of waited signals, but this
> requires two additional syscalls to mask/unmask SIGCANCEL.
>
> Another way is to use sigwaitinfo() in the wrapper, which is permitted
> to return [EINTR]. If [EINTR] is removed from the kernel sigwait(),
> looping on [EINTR] can then be implemented in the wrapper.
>
> Calling pthread_exit from the SIGCANCEL handler is not possible as this
> leaves the program in doubt about any signal consumed by sigwait().
>
A system call can not return EINTR is not flexible, I think why don't we
fix it in libc and libthr, but let kernel returns EINTR?
More information about the freebsd-threads
mailing list