* archival/bunzip2.c (bunzip2_main): Do not remove files if writing to standard
[oweals/busybox.git] / init / reboot.c
index bde8dbd7750d7dc1511f80c9f1ed141e94a81fce..001a3c7d2f8f668b77db566a7fc3145905efb942 100644 (file)
@@ -2,8 +2,8 @@
 /*
  * Mini reboot implementation for busybox
  *
- *
  * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
+ * Copyright (C) 1999-2002 by Erik Andersen <andersee@debian.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  */
 
-#include "internal.h"
+#include "busybox.h"
 #include <signal.h>
 
 extern int reboot_main(int argc, char **argv)
 {
-#ifdef BB_FEATURE_LINUXRC
+#ifdef CONFIG_FEATURE_INITRD
        /* don't assume init's pid == 1 */
-       return(kill(*(findPidByName("init")), SIGINT));
+       long *pid = find_pid_by_name("init");
+       if (!pid || *pid<=0) {
+               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, SIGINT));
+       return(kill(1, SIGTERM));
 #endif
 }