Look for either "init" or "linuxrc" processes

This commit is contained in:
Eric Andersen 2001-10-03 21:26:12 +00:00
parent f0a4ac8216
commit 371ca19f53
6 changed files with 30 additions and 12 deletions

7
halt.c
View File

@ -29,8 +29,11 @@ extern int halt_main(int argc, char **argv)
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
if (!pid || *pid<=0) {
pid_t *pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
return(kill(*pid, SIGUSR1));
#else
return(kill(1, SIGUSR1));

View File

@ -29,8 +29,11 @@ extern int halt_main(int argc, char **argv)
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
if (!pid || *pid<=0) {
pid_t *pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
return(kill(*pid, SIGUSR1));
#else
return(kill(1, SIGUSR1));

View File

@ -29,8 +29,11 @@ extern int poweroff_main(int argc, char **argv)
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
if (!pid || *pid<=0) {
pid_t *pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
return(kill(*pid, SIGUSR2));
#else
return(kill(1, SIGUSR2));

View File

@ -29,8 +29,11 @@ extern int reboot_main(int argc, char **argv)
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
if (!pid || *pid<=0) {
pid_t *pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
return(kill(*pid, SIGTERM));
#else
return(kill(1, SIGTERM));

View File

@ -29,8 +29,11 @@ extern int poweroff_main(int argc, char **argv)
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
if (!pid || *pid<=0) {
pid_t *pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
return(kill(*pid, SIGUSR2));
#else
return(kill(1, SIGUSR2));

View File

@ -29,8 +29,11 @@ extern int reboot_main(int argc, char **argv)
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
pid_t *pid = find_pid_by_name("init");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
if (!pid || *pid<=0) {
pid_t *pid = find_pid_by_name("linuxrc");
if (!pid || *pid<=0)
error_msg_and_die("no process killed");
}
return(kill(*pid, SIGTERM));
#else
return(kill(1, SIGTERM));