Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yousong Zhou <yszhou4tech@gmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix invalid sigprocmask call
Date: Fri, 24 Mar 2017 10:47:00 -0000	[thread overview]
Message-ID: <2b0bab84-e36e-e109-5444-dc84369dddce@redhat.com> (raw)
In-Reply-To: <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


       reply	other threads:[~2017-03-24 10:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1490324519-11228-1-git-send-email-yszhou4tech@gmail.com>
2017-03-24 10:47 ` Pedro Alves [this message]
2017-03-24 12:24   ` Yousong Zhou
2017-03-24 12:39     ` Yousong Zhou
2017-03-24 12:58       ` Pedro Alves
2017-03-24 12:55     ` Pedro Alves
2017-03-24 13:05       ` Yousong Zhou
2017-03-24 13:37         ` Pedro Alves
2017-03-25  0:36           ` Yousong Zhou
2017-03-24 15:35         ` [musl] " Rich Felker
2017-03-24 15:52           ` Pedro Alves
2017-03-24 16:41             ` Rich Felker
2017-03-24 17:34           ` Andreas Schwab
2017-03-24 18:15             ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b0bab84-e36e-e109-5444-dc84369dddce@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yszhou4tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox