26 lines
820 B
C
26 lines
820 B
C
|
/**********************************************************/
|
||
|
/* 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 (;;);
|
||
|
}
|