Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Mini poweroff implementation for busybox |
| 4 | * |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 6 | * |
Rob Landley | 2edf526 | 2006-01-22 02:41:51 +0000 | [diff] [blame] | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 10 | #include <signal.h> |
Eric Andersen | 0246222 | 2003-07-22 09:41:39 +0000 | [diff] [blame] | 11 | #include <stdlib.h> |
| 12 | #include <unistd.h> |
| 13 | #include <getopt.h> |
| 14 | #include <sys/reboot.h> |
| 15 | #include "busybox.h" |
| 16 | #include "init_shared.h" |
| 17 | |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 18 | |
Erik Andersen | e49d5ec | 2000-02-08 19:58:47 +0000 | [diff] [blame] | 19 | extern int poweroff_main(int argc, char **argv) |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 20 | { |
Eric Andersen | 0246222 | 2003-07-22 09:41:39 +0000 | [diff] [blame] | 21 | char *delay; /* delay in seconds before rebooting */ |
| 22 | |
| 23 | if(bb_getopt_ulflags(argc, argv, "d:", &delay)) { |
| 24 | sleep(atoi(delay)); |
| 25 | } |
| 26 | |
Rob Landley | 2edf526 | 2006-01-22 02:41:51 +0000 | [diff] [blame] | 27 | return ENABLE_INIT ? kill(1,SIGUSR2) : bb_shutdown_system(RB_POWER_OFF); |
Eric Andersen | 2cb5507 | 1999-12-10 08:25:07 +0000 | [diff] [blame] | 28 | } |