Getting children PIDs before the main process is killed

List of children processes cannot be obtained after the main process has stopped, so to actually ensure that children processes are also signaled, even when signal causes main process to stop, we must get their PIDs first.