plan9fox/rc/bin/dontkill
cinap_lenrek bce2696b17 dontkill: only use noswap flag to mark processes as not to be terminated on oom
changing procmode has the nasty side effect that notes cannot
be posted to them, prventing sysfatal() and threadexitsall()
to cleanup properly.

recent kernels also check the noswap flag to void killing them
in out of memory condition, so this is really all we need now.
2015-06-15 17:13:19 +02:00

12 lines
319 B
Bash
Executable file

#!/bin/rc
# dontkill regexp - mark invoker's processes with names matching regexp
# as not killable when the kernel runs out of memory
if (! ~ $#* 1) {
echo $0 regexp >[1=2]
exit usage
}
# see /sys/src/9/port/proc.c:/^killbig
psu | awk '$NF ~ /'$1'/ {
print "@{echo noswap >/proc/"$2"/ctl}"
}' | rc >/dev/null >[2=1]