Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. int main()
  5. {
  6. pid t pid;
  7. /* fork a child process */
  8. pid = fork();
  9. if (pid < 0) { /* error occurred */
  10. fprintf(stderr, "Fork Failed");
  11. return 1;
  12. }
  13. else if (pid == 0) { /* child process */
  14. execlp("/bin/ls","ls",NULL);
  15. printf("LINE J");
  16. }
  17. else { /* parent process */
  18. /* parent will wait for the child to complete */
  19. wait(NULL);
  20. printf("Child Complete");
  21. }
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement