Process Termination
Notes
- We know that processes can terminate of their own accord
- In c++/linux/unix
- return from main
- call exit, in any of the forms.
- There are other forms of self termination
- But the os can terminate a process as well
- This is normally done by sending a process a signal.
- This is a software interrupt
- Some can be blocked and some can't
- Some can be ignored, some cant.
- When a child process terminates, a signal is sent to the parent
- This is how wait works, it waits for the signal.
- The signal is a SIGCHILD
- SIGCHILD is normally ignored.
- In linux/unix an interesting process state is zombie
- When a process exites, the kernel informs the parent that the child has exited.
- If the parent doesn't handle this, the child becomes a zombie
- It still has a PCB, but it is greatly reduced.
- It can not be deleted from the system until this information is no longer needed.
- If the parent exits without handling this, systemd reparents the process to the closest ancestor that is a subreaper.
- Which instantly acknowledges the exit status and the child can be deleted.
- By the way, an orphan process is a process whos parent has exited
- These used to become direct children of init, systemd
- But now they get reparented
- But notes suggest this is still systemd.
- Take a look at orphan.cpp and zombie.cpp