Guest User

Untitled

a guest
Sep 29th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. // Answers:
  2. // 1. This is probably not the author's intention, but I didn't call wait(). Sending a signal might also work.
  3.  
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7.  
  8. int main(int argc, char *argv[]) {
  9. int rc = fork();
  10.  
  11. if (rc < 0) {
  12. fprintf(stderr, "fork failed\n");
  13. exit(1);
  14. } else if (rc == 0) {
  15. printf("hello\n");
  16. } else {
  17. waitpid(-1, NULL, 0);
  18. printf("goodbye\n");
  19. }
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment