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