I want to configure a headless server to automatically reboot under catastrophic circumstances. Right now I have configured to make it panic when running out of RAM, and reboot automatically on kernel panic (sysctl kernel.panic=15 reboots 15 seconds after panic).
I want to make it also reboot when it runs out of PID (e.g. in case of a fork bomb). How should I achieve this? Note that invoking a kernel panic is also a solution.
I need a solution for Linux 5.0+ with systemd 239+, and I will appreciate if the solution is also applicable for older versions of Linux and systemd (maybe 4.9 and 237).
Note: I know how to prevent a fork bomb, but my environment makes automatic recovery more important than beforehand prevention. (i.e., resilience > resistance).