#include <time.h>
#include <signal.h>
#include<stdio.h>
#include<stdlib.h>
#include <unistd.h>
#include <string.h>
void handle(union sigval v)
{
time_t t;
char p[32];
time(&t);
strftime(p, sizeof(p), "%T", localtime(&t));
printf("%s thread %lu, val = %d, signal captured.\n", p, pthread_self(), v.sival_int);
return;
}
void handlec(union sigval v) //定时器2产生信号时调用的处理函数
{
time_t t;
char p[32];
time(&t);
strftime(p, sizeof(p), "%T", localtime(&t));
printf("%s thread %lu, val = %d, signal captured.\n", p, pthread_self(), v.sival_int);
return;
}
int main()
{
#include <signal.h>
#include<stdio.h>
#include<stdlib.h>
#include <unistd.h>
#include <string.h>
void handle(union sigval v)
{
time_t t;
char p[32];
time(&t);
strftime(p, sizeof(p), "%T", localtime(&t));
printf("%s thread %lu, val = %d, signal captured.\n", p, pthread_self(), v.sival_int);
return;
}
void handlec(union sigval v) //定时器2产生信号时调用的处理函数
{
time_t t;
char p[32];
time(&t);
strftime(p, sizeof(p), "%T", localtime(&t));
printf("%s thread %lu, val = %d, signal captured.\n", p, pthread_self(), v.sival_int);
return;
}
int main()
{