public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: uc_sigmask set in a sigaction signal handler not honored
Date: Wed, 03 Apr 2019 12:16:00 -0000	[thread overview]
Message-ID: <20190403121555.GV3337@calimero.vinschen.de> (raw)
In-Reply-To: <366918d8-b505-45be-dc28-303579f17341@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

On Apr  3 11:27, Petr Skočík wrote:
> Hi. Correct me if I'm wrong but POSIX appears to define
> 
> https://pubs.opengroup.org/onlinepubs/7908799/xsh/ucontext.h.html
> 
> as, among other things, containing the field:
> 
> sigset_t    uc_sigmask  the set of signals that are blocked when this
>                         context is active
> 
> and it also specifies that the third argument to a .sa_sigaction
> signal handler is a ucontext_t* cast to void*.
> 
> So it should follow that doing
> 
> void act(int Sig, siginfo_t *Info, void *Uctx)
> {
> 	ucontext_t *uctx = Uctx;
> 	sigfillset(&uctx->uc_sigmask);
> }
> 
> from a signal handler should alter the signal mask of the thread the
> signal ran on.
> 
> This is how Linux and MacOS behave, but not CygWin, as the following
> program shows:

What you're asking for is really complicated.

The context given to act is the context at the time the signal function
is called.  In Cygwin (lower case w) this is a copy of the context.

sigfillset() has not the faintest clue where this context comes from, it
just sets the signal mask value without taking any further action.

There are no provisions to control if the called function changes the
context, other than via setcontext / swapcontext, and I don't see that
POSIX requires anything else.  Both functions change the current
thread's sigmask according to the value of uc_sigmask.


HTH,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-04-03 12:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03  9:28 Petr Skočík
2019-04-03 12:16 ` Corinna Vinschen [this message]
2019-04-03 12:43   ` Corinna Vinschen
2019-09-09 17:13 ` malloc(0) crashes with SIGABRT Petr Skočík
2019-09-09 18:27 ` malloc(0) crashing " Petr Skočík
2019-09-12  3:59   ` Brian Inglis
2019-09-12 11:33     ` Kaz Kylheku
2019-09-12 18:05       ` Brian Inglis
2019-09-12 17:38   ` Ken Brown
     [not found]     ` <e20e38ff-49b1-6472-b0a4-faeee0176a7c@gmail.com>
2019-09-13 13:21       ` Ken Brown
2019-04-03 14:39 uc_sigmask set in a sigaction signal handler not honored Petr Skočík
2019-04-03 16:29 ` Corinna Vinschen

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=20190403121555.GV3337@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).