Advertisement
Guest User

Y MARCHE?

a guest
Dec 6th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/types.h>
  4. #include <sys/wait.h>
  5. #include <unistd.h>
  6.  
  7. void fonction(int n){
  8.   if(n <= 0)  printf("MESSAGE D\'ERREUR");
  9.   else{
  10.     pid_t pid;
  11.     pid = fork();
  12.     if( pid == 0) fonction(n-1);
  13.     else
  14.       printf("pid : %d\n", pid);
  15.   }
  16. }
  17.  
  18. int main(int argc, char *argv[]){
  19.   if(atoi(argv[1])>0){
  20.     fonction(atoi(argv[1]));
  21.     return 0;
  22.   }else {
  23.     printf("Erreur");
  24.     return 0;
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement