26 lines
845 B
C
Raw Normal View History

2020-05-01 23:58:52 +02:00
/**********************************************************/
/* DUT INFORMATIQUE - M311 - R. CHIGNOLI */
/* demo_alarm.c : Utilisation du signal SIGALRM par alarm */
/**********************************************************/
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
void rep_SIGALRM ()
{ printf ("\n*** Processus %d : Signal SIGALRM recu\n\n", getpid());
exit(0);
}
int main (int argc, char* argv[])
{
int res;
assert (argc == 2);
signal (SIGALRM, rep_SIGALRM);
printf ("\n*** Processus %d : Je m' endors ......\n", getpid());
res = alarm (atoi(argv[1]));
for (;;);
}