fork download
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/wait.h>
  4.  
  5. int main(int argc, char* argv[]) {
  6.  
  7. pid_t ret1 = 0;
  8. pid_t ret2 = 0;
  9. for (int i = 0; i < 3 ; i ++)
  10. {
  11. ret1 = fork();
  12. if ( ret1 != 0)
  13. break;
  14. else
  15. ret2 = fork();
  16. }
  17. printf ( "hello\n" );
  18. }
  19.  
  20.  
  21.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
hello