Wait
Wait
Review of fork
Fork creates a new child process with a duplicate of memory
The main differences are: 1) The value of PID 2) The return value of fork.
Example
Let’s say I want to count to 100 as fast as possible.
The following code uses multiple cores to count faster! (maybe…)
ZOMBIES!
Zombie processes are a real danger of forking
When a process exits, it enters a “zombie” state while it waits for its parent to accept its return state.
The return state is accepted by wait()
Wait
x = wait(&stat), suspends the process until at least one zombie process exits.
x is the PID of the return
The integer stat stores the returned exit code.
Other useful functions:
exit(int code), terminates calling process and returns error code to parent.
WEXITSTATUS(int status), decodes the exit status to the raw integer returned
waitpid(pid_t pid, &stat), waits for the specified process to send exit signal.
Example
/docProps/thumbnail.jpeg