fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int i = 1;
  5. int count = 0;
  6.  
  7. i = 1;
  8. for( count = 0; count < 3; count++) {
  9. if( i != 0 ) {
  10. i = fork();
  11. } else {
  12. break;
  13. }
  14. }
  15.  
  16. if( i == 0 ) {
  17. printf("%d",count);
  18. }
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
321