Trap abort signal from abort function bus error

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: ) Calls fork three times. (f) Prints eight output lines. Figure 8.14: Examples of programs and their process hierarchies. 408 CHAPTER 8. EXCEPTIONAL CONTROL FLOW creates two processes, and the third fork creates four processes, for a total of eight processes. Each process calls printf, so the program produces eight output lines. Practice Problem 8.1: Consider the following program: code/ecf/forkprob0.c 1 2 3 4 5 6 7 8 9 10 11 #include "csapp.h" int main() { int x = 1; if (Fork() == 0) printf("printf1: x=%d\n", ++x); printf("printf2: x=%d\n", --x); exit(0); } code/ecf/forkprob0.c A. What is the output of the child process? B. What is the output of the parent process? Practice Problem 8.2: How many “hello” output lines does this program print? code/ecf/forkprob1.c 1 2 3 4 5 6 7 8 9 10 11 #include "csapp.h" int main() { int i; for (i = 0; i < 2; i++) Fork(); printf("hello!\n"); exit(0); } code/ecf/forkprob1.c Practice Problem 8.3: How many...
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