Files
BUT2FI_2026_R3.05/tp/tp3/src/exo5.c
T
2026-09-18 14:28:13 +02:00

33 lines
581 B
C

#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;
}