28 lines · c
1#include <stdlib.h>2#include <signal.h>3#include <stdio.h>4#include <unistd.h>5 6void handler (int in)7{8 puts ("in handler routine");9 while (1)10 ;11}12 13void14foo ()15{16 puts ("in foo ()");17 kill (getpid(), SIGUSR1);18}19int main ()20{21 puts ("in main"); // Set breakpoint here22 signal (SIGUSR1, handler);23 puts ("signal handler set up");24 foo();25 puts ("exiting");26 return 0;27}28