Systemcalls Processes
Systemcalls Processes
exec()
p1 p1
Old
Legend: Program
New
Program
p1 p1 c1
tcsh ls
PID=34 PID=34
exec(ls)
c1 c1
March 1, Serguei A. Mokhov, 10
The System wait() Call
• Forces the parent to suspend execution, i.e.
wait for its children or a specific child to die
(terminate is more appropriate terminology,
but a bit less common).
• Example: fork_exec.c
• The wait() causes the parent to wait for any child process.
• The waitpid() waits for the child with specific PID.
• The status, if not NULL, stores exit information of the child,
which can be analyzed by the parent using the W*() macros.
• The return value is:
– PID of the exited process, if no error
– (-1) if an error has happened
Kernel-ru exit()
Zombie
nning
wait() ?
Block
Ready
ed