xref: /plan9/rc/bin/dontkill (revision 1eb50af0143a65e23f026e3eba07642ff398159f)
1#!/bin/rc
2# dontkill regexp - mark invoker's processes with names matching regexp
3#	as not killable when the kernel runs out of memory
4if (! ~ $#* 1) {
5	echo $0 regexp >[1=2]
6	exit usage
7}
8cd /proc
9# see /sys/src/9/port/proc.c:/^killbig
10pids=`{psu | awk '$NF ~ /'$1'/ {print $2}'}
11~ $#pids 0 || chmod -w $pids^/ctl >[2]/dev/null
12