Guest User

Untitled

a guest
Oct 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<unistd.h>
  3. #include<stdlib.h>
  4.  
  5. void main(){
  6. int a,pid;
  7. printf("Do you want to create a process? Press 1 for Yes ");
  8. scanf("%d",&a);
  9. if (a==1){
  10. fork();}
  11. else{printf("Fair enough");}
  12.  
  13. printf("This should print twice");
  14.  
  15. if (pid<0){printf(" Child process not created ");}
  16.  
  17. else if (pid>0){printf(" This is the parent process ");}
  18.  
  19. else{printf(" This is the child process ");}}
  20.  
  21. >Do you want to create a process? Press 1 for Yes 1
  22. >This should print twice This is the child process This should print twice This is the child process
  23.  
  24. >This should be printed twice
  25. >This is child process
  26. >This should be printed twice
  27. >This is parent process
Add Comment
Please, Sign In to add comment