2020-05-01 23:58:52 +02:00

29 lines
890 B
C
Executable File

/******************************************************/
/* DUT INFORMATIQUE - M311 - R. CHIGNOLI */
/* demo_kill_grp_1.c : Utilisation de la routine kill */
/******************************************************/
# include <stdio.h>
# include <signal.h>
#include <unistd.h>
#include <stdlib.h>
int main ()
{ int res;
res = fork ();
if (res != 0)
{
printf ("\nPERE No %d ( GRPID = %d ) : j'attends 5 secondes...\n",
getpid(), getpgrp());
sleep (5);
printf ("\nPERE No %d ( GRPID = %d ) : ... puis je me suicide par kill\n\n", getpid(), getpgrp());
kill (0, SIGKILL);
printf ("\nPERE No %d ( GRPID = %d ) : ... je suis mort\n\n", getpid(), getpgrp());
}
else
{
printf ("\nFILS No %d ( GRPID = %d ) : Je boucle indefiniment ...\n",
getpid(), getpgrp());
for(;;);
}
}