"depot M311"
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,25 +0,0 @@
|
||||
/**********************************************************/
|
||||
/* 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 (;;);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* demo_kill.c : Utilisation de la routine kill */
|
||||
/* */
|
||||
/************************************************/
|
||||
# include <stdio.h>
|
||||
# include <signal.h>
|
||||
# include <sys/types.h>
|
||||
# include <unistd.h>
|
||||
|
||||
int main ()
|
||||
{
|
||||
printf ("\nJe commence et j'attends 3 secondes...\n");
|
||||
sleep (3);
|
||||
printf ("\n... puis je me suicide par kill - %d - \n", getpid());
|
||||
kill (getpid(), SIGKILL);
|
||||
printf ("\n... je suis mort\n");
|
||||
return 0;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/******************************************************/
|
||||
/* 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(;;);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/******************************************************/
|
||||
/* DUT INFORMATIQUE - M311 - R. CHIGNOLI */
|
||||
/* demo_kill_grp_2.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 3 secondes...\n", getpid(), getpgrp());
|
||||
sleep (3);
|
||||
printf ("\nPERE No %d ( GRPID = %d ) : ... puis je me suicide par kill\n", getpid(), getpgrp());
|
||||
kill (0, SIGKILL);
|
||||
printf ("\nPERE No %d ( GRPID = %d ) : ... je suis mort\n", getpid(), getpgrp());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (setpgid (0, getpid()) != 0){
|
||||
perror ("setgpid"); exit (1);
|
||||
}
|
||||
printf ("\nFILS No %d ( GRPID = %d ) : nouveau groupe ...\n", getpid(), getpgrp());
|
||||
printf ("\nFILS No %d ( GRPID = %d ) : J'attends 5 secondes\n", getpid());
|
||||
sleep (5);
|
||||
printf ("\nFILS No %d ( GRPID = %d ) : Et je meurs naturellement !\n\n",
|
||||
getpid());
|
||||
exit (0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user