Recently I found some code which uses signal
:
286 static void sighandler( int signum )
287 {
288 alarmed = 1;
289 signal( signum, sighandler );
290 }
291
292 void set_alarm( int seconds )
293 {
294 alarmed = 0;
295 signal( SIGALRM, sighandler );
296 alarm( seconds );
297 }
I have some troubles to figure out why do I need to call signal
2 times, especially, why do I need to call signal
in sighandler
? I know what the above code does but dont understand why do I need to call signal
2 times.