日期:2014-05-16 浏览次数:20710 次
#include <stdio.h>
#include <pthread.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
pthread_t tid1,tid2;
sigset_t sigs;
void* fun1(void* d)
{
int s;
while(1)
{
sigwait(&sigs,&s);
printf("action!\n");
}
}
void* fun2(void *d)
{
while(1)
{
sleep(1);
pthread_kill(tid1,35);
}
}
int main()
{
sigemptyset(&sigs);
sigaddset(&sigs,35);
pthread_create(&tid1,0,fun1,0);
sleep(1);
pthread_create(&tid2,0,fun2,0);
pthread_join(tid1,NULL);
pthread_join(tid2,NULL);
return 0;
}