xref: /original-bsd/old/dbx/tests/cc/signal.c (revision de2121ab)
1*de2121abSbostic /*
2*de2121abSbostic  * Test of tracebacks from signal handlers.
3*de2121abSbostic  */
4*de2121abSbostic 
5*de2121abSbostic #include <stdio.h>
6*de2121abSbostic #include <signal.h>
7*de2121abSbostic 
8*de2121abSbostic int catch(), secondcatch();
9*de2121abSbostic 
main()10*de2121abSbostic main()
11*de2121abSbostic {
12*de2121abSbostic     signal(SIGQUIT, catch);
13*de2121abSbostic     kill(getpid(), SIGQUIT);
14*de2121abSbostic     printf("back in main\n");
15*de2121abSbostic }
16*de2121abSbostic 
catch()17*de2121abSbostic catch()
18*de2121abSbostic {
19*de2121abSbostic     printf("in catch\n");
20*de2121abSbostic     sigsetmask(0);
21*de2121abSbostic     signal(SIGQUIT, secondcatch);
22*de2121abSbostic     kill(getpid(), SIGQUIT);
23*de2121abSbostic     printf("back in catch\n");
24*de2121abSbostic }
25*de2121abSbostic 
secondcatch()26*de2121abSbostic secondcatch()
27*de2121abSbostic {
28*de2121abSbostic     printf("in secondcatch\n");
29*de2121abSbostic }
30