
The Linux kernel's OOM (out of memory) Killer has a method to determine which processes get killed first in a critical situation: it's called "magic." No, not really. It is complicated, though, and it offers a "user-friendly" way to help the kernel make its decision. oom_score is located in /proc/ under the number of each running process. The oom_score for each process is based on factors such as memory use and running time. The process directory also contains oom_adj, which, as the name suggests, allows one to adjust the score of the process. Think of it like nice, but for killing, not running.
If TerminateSafe=true were implemented on Linux, it would likely signal the desktop environment to adjust oom_score to put the application on the top op the assassination list using oom_adj. Other OSes might use a different method or not support the key at all.
The problem with this approach is that the process the .desktop file spawns may not even be the main process if the file calls a script. The situation is made worse by processes that fork. Luckily, the kernel offers process groups to handle this situation, something Systemd is planning to use.
I hope you've heard of Systemd, the init/upstart replacement with a model half way between launchd and inetd. If you haven't you should take a look at it.
No comments:
Post a Comment