Search code examples
unixposixparent-child

Can a child be killed by a not-parent process?


I'm making a project in which the parent forks a terminator process that kills one random child of the parent. It seems that it creates some problems.

Is it allowed?


Solution

  • Not only is that allowed: any process running as the same user or as the root user can kill any other process.

    Running as my user ID in a terminal I can kill anything with my user ID. Even the terminal that I am running in. Or my GUI process.

    The only process in Unix OS types that is immune to kill is PID 1 aka init. Because killing init would result in an immediate kernel panic. If PID 1 exits for any reason, such as an internal bug and segmentation fault, there's an immediate kernel panic.