This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

uc_sigmask set in a sigaction signal handler not honored


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]