This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix invalid sigprocmask call
- From: Pedro Alves <palves at redhat dot com>
- To: Yousong Zhou <yszhou4tech at gmail dot com>, gdb-patches at sourceware dot org
- Date: Fri, 24 Mar 2017 10:47:09 +0000
- Subject: Re: [PATCH] Fix invalid sigprocmask call
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 986E38123D
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 986E38123D
- References: <1490324519-11228-1-git-send-email-yszhou4tech@gmail.com>
On 03/24/2017 03:01 AM, Yousong Zhou wrote:
> The POSIX document says
>
> The pthread_sigmask() and sigprocmask() functions shall fail if:
>
> [EINVAL]
> The value of the how argument is not equal to one of the defined values.
>
> and this is how musl-libc is currently doing. Fix the call to be safe
> and correct
>
> [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html
>
I don't agree. It's a musl bug. Please fix it / file a musl bug.
Note that that document also says (emphasis mine):
If the argument set is not a null pointer, it points to a set of signals to
be used to CHANGE the currently blocked set.
The argument how indicates the way in which the set is CHANGED, and the
application shall ensure it consists of one of the following values:
So the requirement to pass in one of SIG_BLOCK/SIG_SETMASK/SIG_UNBLOCK
only applies when we're CHANGING the set.
The Linux man pages also say (emphasis mine):
If set is NULL, then the signal mask is unchanged (i.e., how is IGNORED), but the
current value of the signal mask is nevertheless returned in oldset (if it is not NULL).
And this is AFAIK the historical Unix behavior. For example,
"Advanced Programming in the UNIX Environment, 3rd edition"
says the same, and explicitly gives such an
example (section 10.13, page 347). See:
https://books.google.pt/books?id=kCTMFpEcIOwC&pg=PA347&lpg=PA347&dq=sigprocmask+with+0+how&source=bl&ots=zvMvUNTumH&sig=u3b_iklV_mOcZRt0mNKkbj3dRFU&hl=en&sa=X&ved=0ahUKEwjl5b_Q9u7SAhUEPhQKHVsBCrM4ChDoAQguMAU#v=onepage&q=sigprocmask%20with%200%20how&f=false
Thanks,
Pedro Alves