"debut TD0"
This commit is contained in:
25
2019-2020/S3T_TP_05_PROCESSUS-4-SIGNAUX/Demonstrations/demo_alarm.c
Executable file
25
2019-2020/S3T_TP_05_PROCESSUS-4-SIGNAUX/Demonstrations/demo_alarm.c
Executable file
@@ -0,0 +1,25 @@
|
||||
/**********************************************************/
|
||||
/* 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 (;;);
|
||||
}
|
Reference in New Issue
Block a user