fork download
  1. #include<stdio.h>
  2. #include<unistd.h>
  3.  
  4. int main()
  5. {
  6. int x,ch;
  7. char cmd[20];
  8. int pid=fork();
  9. if(pid==0)
  10. {
  11. printf("child process");
  12. do
  13. {
  14. printf("Enter the command");
  15. scanf("%s",&cmd);
  16. system(cmd);
  17. printf("Enter 1 to continue, anything else to exit");
  18. scanf("%d",&ch);
  19. }
  20. while(ch==1);
  21. }
  22. else
  23. wait();
  24. }
Success #stdin #stdout #stderr 0.01s 5280KB
stdin
Standard input is empty
stdout
child processEnter the commandEnter 1 to continue, anything else to exit
stderr
sh: 1: Syntax error: ")" unexpected