1 /* Ltrace Test : signals.c. 2 Objectives : Verify that ltrace can trace user defined signal. 3 This file was written by Yao Qi <qiyao@cn.ibm.com>. */ 4 5 #include<stdio.h> 6 #include<signal.h> 7 #include <sys/types.h> 8 9 #define LOOP 7 10 11 void handler(int signum,siginfo_t * info,void * act)12handler(int signum,siginfo_t *info,void *act) 13 { 14 /* Trace printf in signal handler. */ 15 printf("sival_int = %d\n",info->si_value.sival_int); 16 } 17 18 int main()19main () 20 { 21 struct sigaction act; 22 union sigval mysigval; 23 int i; 24 int sig; 25 pid_t pid; 26 27 mysigval.sival_int=0; 28 29 /* Use an user-defined signal 1. */ 30 sig = SIGUSR1; 31 pid=getpid(); 32 33 sigemptyset(&act.sa_mask); 34 act.sa_sigaction=handler; 35 act.sa_flags=SA_SIGINFO; 36 37 if(sigaction(sig,&act,NULL) < 0) 38 { 39 printf("install sigal error\n"); 40 } 41 42 for(i=0; i<LOOP; i++) 43 { 44 sleep(1); 45 sigqueue(pid,sig,mysigval); 46 } 47 return 0; 48 } 49