Signals


Using Sigwait

void * sigwaiter(void * data)
{
	int sig;
	sigset_t set;

	sigemptyset(&set);
	sigaddset(&set, SIGHUP);
	sigaddset(&set, SIGINT);

	while (sigwait(&set, &sig) == 0) {
		switch(sig) {
		case SIGHUP:
			...
			break;
		case SIGINT:
			...
			break;
		default:
			break;
		}
	}	
	
}

int main()
{
	sigset_t set;
	pthread_t thread;

	sigfillset(&set);
	pthread_sigmask(SIG_BLOCK, &set, NULL);
	pthread_create(&thread, NULL, sigwaiter, NULL);
	
	...
}


[TOP] [BACK] [FORWARD]


Prepared by Chris Provenzano (proven@mit.edu)