This commit is contained in:
2025-09-19 14:35:18 +02:00
parent e30e2a51e4
commit 2f0bb873a7

32
tp/tp3/src/exo4.c Normal file
View File

@@ -0,0 +1,32 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/wait.h>
int main(int argc, char *argv[])
{
pid_t p;
int status;
p = fork();
assert( p >= 0);
if ( p == 0){
printf("@retour de fork = %d pid = %d ppid = %d\n",p,getpid(),getppid());
sleep(4);
exit(2);
}
printf("@retour de fork = %d pid = %d ppid = %d\n",p,getpid(),getppid());
assert( wait(&status) >= 0);
if (WIFEXITED(status))
printf("code retour fils = %d\n",WEXITSTATUS(status));
execlp("ls","totototo","-l","/",NULL);
/* code ici */
assert(0);
return 0;
}