1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<signal.h>
int main(int argc, char *argv[])
{
pid_t pid;
char reponse;
pid=fork();
if(pid==0)
{
while(1){
printf("hello");
reponse=getchar();
if(reponse==atoi("s"))
{
kill(getpid(),SIGSTOP);
}
else if(reponse==atoi("r"))
{
kill(getpid(), SIGCONT);
}
if(reponse==atoi("q"))
{
kill(getpid(),SIGTERM);
}
}
}
if(pid>0)
{
printf("(s)---> endormir fils\n");
printf("(r)---> redémarre fils");
printf("(q)---> tuer le fils");
}
} |
Partager