fork download
  1. // Version 3 - Process Creation with Switch
  2. #include <stdio.h>
  3. #include <unistd.h>
  4.  
  5. int main() {
  6. printf("hello\n");
  7. switch(fork()) {
  8. case 0:
  9. printf("hello\n");
  10. if(fork())
  11. fork();
  12. break;
  13. default:
  14. if(fork() == 0) {
  15. printf("hello\n");
  16. fork();
  17. } else {
  18. printf("hello\n");
  19. if(fork() == 0)
  20. printf("hello\n");
  21. }
  22. }
  23. printf("hello\n");
  24. return 0;
  25. }
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello