[PATCH] replace cad_pid by a struct pid

There are a few places in the kernel where the init task is signaled.  The
ctrl+alt+del sequence is one them.  It kills a task, usually init, using a
cached pid (cad_pid).

This patch replaces the pid_t by a struct pid to avoid pid wrap around
problem.  The struct pid is initialized at boot time in init() and can be
modified through systctl with

	/proc/sys/kernel/cad_pid

[ I haven't found any distro using it ? ]

It also introduces a small helper routine kill_cad_pid() which is used
where it seemed ok to use cad_pid instead of pid 1.

[[email protected]: cleanups, build fix]
Signed-off-by: Cedric Le Goater <[email protected]>
Cc: Eric W. Biederman <[email protected]>
Cc: Martin Schwidefsky <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Cedric Le Goater 2006-10-02 02:19:00 -07:00 • committed by Linus Torvalds
commit 9ec52099e4
11 changed files with 48 additions and 16 deletions

View file

@ -84,8 +84,7 @@
static void deferred_poweroff(void *dummy)
{
extern int cad_pid; /* from kernel/sys.c */
if (kill_proc(cad_pid, SIGINT, 1)) {
if (kill_cad_pid(SIGINT, 1)) {
/* just in case killing init process failed */
machine_power_off();
}