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]

SA_SIGINFO and signal info ?


Hi,

Cygwin defines SA_SIGINFO, but it doesn't seem to be implemented: the
following program gets in "info" just 0x0 or a strange pointer. Could
it be supported somehow? The bit of information I'd really need is
info->si_code, so as to know whether the signal is sent by "kernelspace"
(because of alarm, setitimer, ...) or by "userspace" (kill, raise).

Regards,
Samuel

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

void handler (int sig, siginfo_t *info, void *uc) {
	fprintf (stderr,"%d: %p %p\n", sig, info, uc);
}

void *foo (void *bar) {
	while(1) pause ();
	return NULL;
}

int main (void) {
	struct sigaction sa;
	pthread_t t;
	sigemptyset (&sa.sa_mask);
	sa.sa_flags = SA_SIGINFO;
	sa.sa_sigaction = handler;
	sigaction (SIGALRM, &sa, NULL);
	sigaction (SIGINT, &sa, NULL);
	sigaction (SIGWINCH, &sa, NULL);
	pthread_create (&t,NULL,foo,NULL);
	alarm (5);
	pthread_kill (t,SIGINT);
	raise (SIGINT);
	sleep (10);
	sleep (10);
	return 0;
}

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


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