This is test1.c in view mode; [Download] [Up]
/*
* FILE: A test of pthread_sigaction
*/
#include <pthread.h>
#include <stdio.h>
#include <utils.h>
extern int getpid( void );
void
handler( int sig )
{
pthread_lock_global_np();
printf("Caught %s[%d]!\n", sys_signame[sig], sig );
pthread_unlock_global_np();
}
int main( int argc, char *argv[] )
{
struct sigaction act;
struct timespec ts = { 0, 50000 };
int i, signo = NSIG;
printf("pid %d\n", getpid());
for(i = 1; i < NSIG; i++ )
{
if( i == 9 )
continue;
act.sa_handler = handler;
sigemptyset( &act.sa_mask );
pthread_sigaction_np( i, &act, NULL );
}
while( signo-- > 0 )
{
pthread_delay_np( &ts );
pthread_kill( NULL, signo );
}
printf("success!");
return(0);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.