summaryrefslogtreecommitdiff
path: root/rc/bin/dontkill
blob: a471aadb8254962c75aee662bf3b8c356fae5ff6 (plain)
1
2
3
4
5
6
7
8
9
10
#!/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
pids=`{psu | awk '$NF ~ /'$1'/ {print $2}'}
~ $#pids 0 || for(p in /proc/^$pids^/ctl){chmod +w $p; echo noswap >$p; chmod -w $p}