Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<unistd.h>
  3. int main() {
  4. pid_t pid;
  5. pid = fork();
  6. if (pid<0) {
  7. fprintf(stderr, "Fork Failed");
  8. return 1;
  9. }
  10. else if (pid == 0) {
  11. printf(“Child (pid=%d) started \n”,pid);
  12. execlp("/bin/ps","ps",NULL);
  13. }
  14. else {
  15. printf("Parent (with child pid=%d) waiting for child to complete\n",pid); wait(NULL);
  16. printf("Child Complete\n");
  17. }
  18. return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement