853 receiving signals when the kernel is returning

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { if (WIFEXITED(status)) printf("child %d terminated normally with exit status=%d\n", retpid, WEXITSTATUS(status)); else printf("child %d terminated abnormally\n", retpid); } /* The only normal termination is if there are no more children */ if (errno != ECHILD) unix_error("waitpid error"); exit(0); } code/ecf/waitpid2.c Figure 8.16: Using waitpid to reap zombie children in the order they were created. 414 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 CHAPTER 8. EXCEPTIONAL CONTROL FLOW #include "csapp.h" int main() { int status; pid_t pid; printf("Hello\n"); pid = Fork(); printf("%d\n", !pid); if (pid != 0) { if (waitpid(-1, &status, 0) > 0) { if (WIFEXITED(status) != 0) printf("%d\n", WEXITSTATUS(status)); } } printf("Bye\n"); exit(2); } code/ecf/waitprob1.c A. How many output lines does this program generate? B. What is one possible ordering of these output lines? 8.4.4 Putting Processes to Sleep The sleep function suspends a process for some period of time. #include <unist...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online