The fork system call creates a child process that is

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: ork(). The fork system call creates a child process that is a clone of the parent. • Child has a (virtual) copy of the parent’s virtual memory (VAS). • Child is running the same program as the parent. • Child inherits open file descriptors from the parent. • Child begins life with the same register values as parent. The The child process may execute a different program in its context with a separate exec() system call. Unix Fork/Exec/Exit/Wait Unix Fork/Exec/Exit/Wait Example fork fork parent fork child initialize child context exec int pid = fork(); Create a new process that is a clone of its parent. exec*(“program” exec*(“program” [, argvp, envp]); Overlay the calling process virtual memory with a new program, and transfer control to it. exit(status); Exit with status, destroying the process. wait exit int int pid = wait*(&status); Wait for exit (or other status change) of a child. Corner cases: orphans and zombies Example: Example: Process Creation in Unix int pid; int status = 0; if (pid =...
View Full Document

Ask a homework question - tutors are online