24 lines
399 B
C
24 lines
399 B
C
|
/* Auteur : */
|
||
|
|
||
|
|
||
|
#include <sys/types.h>
|
||
|
#include <unistd.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
|
||
|
int i, n = 3;
|
||
|
pid_t childpid;
|
||
|
|
||
|
for (i=0; i<n; i++) {
|
||
|
if ((childpid = fork()) == -1) break;
|
||
|
if (childpid == 0)
|
||
|
printf("Processus %d avec pere %d, i = %d\n", getpid(), getppid(), i);
|
||
|
}
|
||
|
|
||
|
while (wait(NULL) >= 0)
|
||
|
;
|
||
|
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|