fork download
  1. #include <stdio.h>
  2.  
  3. int main () {
  4. if ( fork () != 0) {
  5. if ( fork () != 0) {
  6. printf ( " hello1 \n " ) ;
  7. } else {
  8. fork () ;
  9. }
  10. printf ( " hello2 \n " ) ;
  11. } else {
  12. if ( fork () != 0) {
  13. printf ( " hello3 \n " ) ;
  14. } else {
  15. fork () ;
  16. }
  17. printf ( " hello4 \n " ) ;
  18. }
  19. printf ( " hello5 \n " ) ; // <-- this one !
  20. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
 hello1 
  hello2 
  hello5 
  hello2 
  hello5 
  hello3 
  hello4 
  hello5 
  hello2 
  hello5 
  hello4 
  hello5 
  hello4 
  hello5