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	20
10 
11 void
handler(int signum,siginfo_t * info,void * act)12 handler(int signum,siginfo_t *info,void *act)
13 {
14 }
15 
16 int
main()17 main ()
18 {
19   struct sigaction act;
20   union sigval mysigval;
21   int i;
22   int sig;
23   pid_t pid;
24 
25   mysigval.sival_int=0;
26   sig = SIGUSR1;
27   pid=getpid();
28 
29   sigemptyset(&act.sa_mask);
30   act.sa_sigaction=handler;
31   act.sa_flags=SA_SIGINFO;
32 
33   if(sigaction(sig,&act,NULL) < 0)
34     {
35       printf("install sigal error\n");
36     }
37 
38   for(i=0; i< LOOP; i++)
39     {
40       usleep(100);
41       sigqueue(pid,sig,mysigval);
42     }
43   return 0;
44 }
45