fork download
  1. #include<stdio.h>
  2. #include<unistd.h>
  3. void red()
  4. {
  5. printf("red");
  6.  
  7. }
  8. void green()
  9. {
  10. printf("green");
  11. }
  12. int main()
  13. {
  14. fork();
  15. int color;
  16. color=fork();
  17. if(color==0)
  18. fork();
  19. red();
  20. if(color==0)
  21. fork();
  22. green();
  23. return 0;
  24.  
  25. }
Success #stdin #stdout 0s 1720KB
stdin
Standard input is empty
stdout
redgreenredgreen