fork download
  1. #include <stdio.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #define N 3
  5. int main()
  6. {
  7. int i,p;
  8. for(i=0; i<N; i++){
  9. printf("%d %d\n", i, getpid());
  10. if(p=fork()){
  11. printf("Rotto %d\n", p);
  12. break;
  13. }
  14. }
  15. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
0 1187384
Rotto 1187387
0 1187384
1 1187387
Rotto 1187388
0 1187384
1 1187387
2 1187388
Rotto 1187389
0 1187384
1 1187387
2 1187388