Unformatted text preview: ork().
The fork system call creates a child process that is a clone of the
• 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 parent fork child initialize
child context exec int pid = fork();
Create a new process that is a clone of
exec*(“program” [, argvp, envp]);
Overlay the calling process virtual
memory with a new program, and
transfer control to it.
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
- Summer '14
- Operating Systems, Computer multitasking