aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--halt.c5
-rw-r--r--init/halt.c5
-rw-r--r--init/poweroff.c5
-rw-r--r--init/reboot.c5
-rw-r--r--poweroff.c5
-rw-r--r--reboot.c5
6 files changed, 24 insertions, 6 deletions
diff --git a/halt.c b/halt.c
index e875d04f0..10dcb4225 100644
--- a/halt.c
+++ b/halt.c
@@ -28,7 +28,10 @@ extern int halt_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGUSR1));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGUSR1));
#else
return(kill(1, SIGUSR1));
#endif
diff --git a/init/halt.c b/init/halt.c
index e875d04f0..10dcb4225 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -28,7 +28,10 @@ extern int halt_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGUSR1));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGUSR1));
#else
return(kill(1, SIGUSR1));
#endif
diff --git a/init/poweroff.c b/init/poweroff.c
index 007099d4d..8bb20e9bb 100644
--- a/init/poweroff.c
+++ b/init/poweroff.c
@@ -28,7 +28,10 @@ extern int poweroff_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGUSR2));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGUSR2));
#else
return(kill(1, SIGUSR2));
#endif
diff --git a/init/reboot.c b/init/reboot.c
index 74d2cf643..35c147b34 100644
--- a/init/reboot.c
+++ b/init/reboot.c
@@ -28,7 +28,10 @@ extern int reboot_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGTERM));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGTERM));
#else
return(kill(1, SIGTERM));
#endif
diff --git a/poweroff.c b/poweroff.c
index 007099d4d..8bb20e9bb 100644
--- a/poweroff.c
+++ b/poweroff.c
@@ -28,7 +28,10 @@ extern int poweroff_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGUSR2));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGUSR2));
#else
return(kill(1, SIGUSR2));
#endif
diff --git a/reboot.c b/reboot.c
index 74d2cf643..35c147b34 100644
--- a/reboot.c
+++ b/reboot.c
@@ -28,7 +28,10 @@ extern int reboot_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGTERM));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGTERM));
#else
return(kill(1, SIGTERM));
#endif