Move the fork_monitor code to a separate file