Created attachment 277043 [details, diff] Add support for omitting some proccesses in killproc This patch allows one to specify a list of PIDs to omit when killing processes in killprocs initscript on system shutdown/reboot. This is necessary for example when rootfs is a file on an NTFS partition. As ntfs-3g uses FUSE, mounting host filesystem spawns a process. If the process is killed by killprocs, clean unmounting of root (and hostfs) becomes impossible.
The issue I see with this patch is that you would have to manually edit the /etc/conf.d/killprocs file after every boot to specify the processes you want to skip. That doesn't seem to be a very good way to do this; is there not another way to specify the processes?
Comment on attachment 277043 [details, diff] Add support for omitting some proccesses in killproc yeah, this patch is unacceptable
Well, we do the following: initramfs mounts NTFS partition and gets PID of ntfs-3g process. Next, it mounts a tmpfs somwhere under newroot and puts there a file containing the PID (tmpfs seems to be the only way to pass information from initramfs [the same idea is used in systemd's implementation]) and some other stuff. /etc/conf.d/killprocs: DONTKILL_PIDS=`[ -f "/bootinfo/dontkill" ] && cat /bootinfo/dontkill` Actually I was planning to submit one more patch here and the whole story of booting Gentoo from NTFS to OpenRC mailing list with full deatils. I thought it could be interresting. Believe me, it works :). Any better ideas on how to pass PID from initramfs to killprocs?
Hi, please look at the rc_nostop setting in /etc/rc.conf. Does this allow you to do what you want? You should be able to list the names of services there you do not want stopped.
Hello, rc_nostop is definitely not what we need. We still want killprocs to be executed because we still want remaining processes killed EXCEPT for ONE — the one which keeps host filesystem mounted. Here are the points: a) We do want killprocs to kill almost all processes as they are not supposed to be still alive by the time killprocs is started. b) We don't want killprocs to kill that particular process => we need a way to protect it.
(In reply to comment #5) > Hello, > > rc_nostop is definitely not what we need. > We still want killprocs to be executed because we still want remaining > processes killed EXCEPT for ONE — the one which keeps host filesystem mounted. Isn't that process that keeps the host filesystem mounted a service of its own -- maybe /etc/init.d/ntfs3g or something?I don't run ntfs3g, so I don't know how it works. > Here are the points: > a) We do want killprocs to kill almost all processes as they are not supposed > to be still alive by the time killprocs is started. > b) We don't want killprocs to kill that particular process => we need a way to > protect it. Another option might be to pass the names of processes to kilprocs and have it use pidof $names to look up the names then use the -o option like it did in your previous patch.
we could add KILLALL5_OPTS to /etc/conf.d/killprocs. then we do: eval killall15 -15 ${KILLALL5_OPTS} then you could add to your conf.d: KILLALL5_OPTS='-o `pidof ntfs`'
The suggestion in comment #7 has been implemented in commit 013e7fb.
http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commitdiff;h=013e7fb9fc08acd33e944659ff8e7a18aee2b69f
(In reply to comment #6) > Isn't that process that keeps the host filesystem mounted a service of its own > -- maybe /etc/init.d/ntfs3g or something?I don't run ntfs3g, so I don't know > how it works. No, it's not a service as it it started from initramfs. There is no OpenRC there :). Furthermore killprocs won't check if the process belongs to a service, it will kill it anyway. > Another option might be to pass the names of processes to kilprocs and have it > use pidof $names to look up the names then use the -o option like it did in > your previous patch. Well, I believe that there is nothing special with the name of mount.ntfs-3g process. killprocs' job is to kill remaining misbehaving ones and there might be other mount.ntfs3g processes which we DO want to kill (well, hm, killprocs runs after localmount unmounts filesystems but still choosing by NAME is not that great).
(In reply to comment #7) > then you could add to your conf.d: > KILLALL5_OPTS='-o `pidof ntfs`' The basic idea is that we don't want system administrator to mess up with all this. He just says to OpenRC: initramfs will give yout a list of processes that you must not touch. It is initramfs' duty to figure out which processes can't be killed before we switch to deinitramfs, not user's. Running system never knows where its root is located physically. There is not just NTFS there are other types of block layers that may require one or more 'special' processes. Your solution is also acceptable as we will do KILLALL5_OPTS='-o `[ -f "/bootinfo/dontkill" ] && cat /bootinfo/dontkill`'. But... you know, killall5 has only one option :).
openrc knows nothing of initramfs, and we arent about to start developing/encoding some ABI between the two. killall5 *today* only has one option (-o), but how that gets expanded is up to the end user. your example code also isnt quite right as you dont want to pass "-o" if the file doesnt exist ...
(In reply to comment #12) > openrc knows nothing of initramfs, and we arent about to start > developing/encoding some ABI between the two. Sure. But using variable for pids instead of variable for all options is not an interface between OpenRC and initramfs, but between OpenRC and sysvinit (killall5). I don't think it's that bad. > killall5 *today* only has one option (-o), but how that gets expanded is up to > the end user. your example code also isnt quite right as you dont want to pass > "-o" if the file doesnt exist ... Yeah, right. I just was a bit in a hurry. Thank you!
I am closing this since we seem to have agreed on a solution. This will be part of the next openrc release as shown on the tracker bug this bug blocks.