#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

/* pstree output when trying fil 5

-+= 51526 yunes ./fil 5
 \-+- 51527 yunes ./fil 5
   \-+- 51528 yunes ./fil 5
     \-+- 51529 yunes ./fil 5
       \-+- 51530 yunes ./fil 5
         \--- 51531 yunes (fil)

*/

// warning: no real error handling there...
int main(int argc,char *argv[]) {
  int n;
  sscanf(argv[1],"%d",&n);
  for (int i=0; i<n; i++) {
    pid_t p = fork();
    switch(p) {
    case -1:
      break;
    case 0:
      break;
    default:
      sleep(10); // for testing purpose
      wait(NULL);
      exit(0);
    }
  }
}