"debut TD0"
This commit is contained in:
23
2019-2020/S3T_TP_03_PROCESSUS-2-PROG/Demonstrations/demo_sleep.c
Executable file
23
2019-2020/S3T_TP_03_PROCESSUS-2-PROG/Demonstrations/demo_sleep.c
Executable file
@@ -0,0 +1,23 @@
|
||||
/*************************************************/
|
||||
/* demo_sleep : Utilisation de "sleep" */
|
||||
/*************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
/* argc : compteur d'arguments */
|
||||
/* argv : tableau de pointeurs de chaines */
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf (stderr, "Syntaxe : %s duree-du-sleep\n", argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
printf("\n%s (Pid = %d): Regardez-moi avec ps ... Je m'endors %s secondes.\n",
|
||||
argv[0], getpid(),argv[1]);
|
||||
sleep (atoi(argv[1]));
|
||||
printf("%s (Pid = %d): Je me reveille après %s secondes.\n\n",
|
||||
argv[0], getpid(), argv[1]);
|
||||
}
|
||||
Reference in New Issue
Block a user