public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Petr Skočík" <pskocik@gmail.com>
To: cygwin@cygwin.com
Subject: uc_sigmask set in a sigaction signal handler not honored
Date: Wed, 03 Apr 2019 09:28:00 -0000	[thread overview]
Message-ID: <366918d8-b505-45be-dc28-303579f17341@gmail.com> (raw)

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:

#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/time.h>
void prmask(void)
{
	sigset_t mask; pthread_sigmask(SIG_SETMASK,0,&mask);
	for(int i=1; i<=64; i++){ printf("%d", sigismember(&mask,i)); } puts("");
}
void act(int Sig, siginfo_t *Info, void *Uctx)
{
	ucontext_t *uctx = Uctx;
	sigfillset(&uctx->uc_sigmask);
}
int main()
{
	struct sigaction sa;
	sa.sa_sigaction = act;
	sa.sa_flags = SA_SIGINFO;
	sigfillset(&sa.sa_mask);

	prmask();
	sigaction(SIGINT,&sa,0);
	sigaction(SIGALRM,&sa,0);
	if(1)
		setitimer(ITIMER_REAL,&(struct itimerval){.it_value={.tv_usec=10000}},0);
	pause();
	prmask();
}

I think this is a bug, so I'm reporting it. Do you think it can be fixed
in the near future?

Best regards,
Petr Skocik


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

             reply	other threads:[~2019-04-03  9:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03  9:28 Petr Skočík [this message]
2019-04-03 12:16 ` Corinna Vinschen
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=366918d8-b505-45be-dc28-303579f17341@gmail.com \
    --to=pskocik@gmail.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).