If a process has a pending signal of type then any

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: til it can be reaped by the parent. End Aside. If the parent process terminates without reaping its zombie children, the kernel arranges for the init process to reap them. The init process has a PID of 1 and is created by the kernel during system initialization. Long-running programs such as shells or servers should always reap their zombie children. Even though zombies are not running, they still consume system memory resources. A process waits for its children to terminate or stop by calling the waitpid function. #include <sys/types.h> #include <sys/wait.h> pid t waitpid(pid t pid, int *status, int options); returns: PID of child if OK, 0 (if WNOHANG) or -1 on error The waitpid function is complicated. By default (when options = 0), waitpid suspends execution of the calling process until a child process in its wait set terminates. If a process in the wait set has already 410 CHAPTER 8. EXCEPTIONAL CONTROL FLOW terminated at the time of the call, then waitpid returns immediately. In either case, waitpid returns...
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