This preview shows page 1. Sign up to view the full content.
Unformatted text preview: x function lists the header ﬁles to include whenever you use that function in your code. Also, in order to check return codes such as ECHILD and EINTR, you must include errno.h. To simplify our code examples, we include a single header ﬁle called csapp.h that includes the header ﬁles for all of the functions used in the book. The csapp.h header ﬁle is listed in Appendix A. End Aside. Examples
Figure 8.15 shows a program that creates Æ children, uses waitpid to wait for them to terminate, and then checks the exit status of each terminated child. When we run the program on our Unix system, it produces the following output:
unix> ./waitpid1 child 22966 terminated normally with exit status=100 child 22967 terminated normally with exit status=101 Notice that the program reaps the children in no particular order. Figure 8.16 shows how we might use waitpid to reap the children from Figure 8.15 in the same order that they were created by the parent. Practice Problem 8.4:
Consider the following program: code/ecf/waitprob1.c 412 CHAPTER 8. EXCEPTIONAL CONTROL FLO...
View Full Document