Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 371625

Summary: sys-apps/openrc: omit some processes in killprocs
Product: Gentoo Hosted Projects Reporter: Kirill Elagin <kirelagin>
Component: OpenRCAssignee: OpenRC Team <openrc>
Status: RESOLVED FIXED    
Severity: enhancement CC: kirelagin
Priority: Normal Keywords: InVCS
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 374183    
Attachments: Add support for omitting some proccesses in killproc

Description Kirill Elagin 2011-06-14 14:24:37 UTC
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.
Comment 1 William Hubbs gentoo-dev 2011-06-15 03:56:19 UTC
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 2 SpanKY gentoo-dev 2011-06-17 01:39:07 UTC
Comment on attachment 277043 [details, diff]
Add support for omitting some proccesses in killproc

yeah, this patch is unacceptable
Comment 3 Kirill Elagin 2011-06-17 08:27:32 UTC
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?
Comment 4 William Hubbs gentoo-dev 2011-06-23 22:36:17 UTC
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.
Comment 5 Kirill Elagin 2011-06-23 22:55:19 UTC
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.
Comment 6 William Hubbs gentoo-dev 2011-06-23 23:34:16 UTC
(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.
Comment 7 SpanKY gentoo-dev 2011-06-23 23:43:11 UTC
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`'
Comment 8 William Hubbs gentoo-dev 2011-06-24 03:03:34 UTC
The suggestion in comment #7 has been implemented in commit 013e7fb.
Comment 10 Kirill Elagin 2011-06-24 07:25:52 UTC
(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).
Comment 11 Kirill Elagin 2011-06-24 07:35:52 UTC
(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 :).
Comment 12 SpanKY gentoo-dev 2011-06-24 17:50:08 UTC
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 ...
Comment 13 Kirill Elagin 2011-06-24 18:37:58 UTC
(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!
Comment 14 William Hubbs gentoo-dev 2011-08-31 15:18:21 UTC
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.