+/* vi: set sw=4 ts=4: */
/*
* Mini poweroff 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
-poweroff_main(int argc, char ** argv)
+extern int poweroff_main(int argc, char **argv)
{
- /* don't assume init's pid == 1 */
- exit( kill(findInitPid(), SIGUSR2));
+#ifdef CONFIG_FEATURE_INITRD
+ /* don't assume init's pid == 1 */
+ 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, SIGUSR2));
+#else
+ return(kill(1, SIGUSR2));
+#endif
}