blob: b79bcd036a2e4d2f069b63f7f7b3891e9c023447 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen2cb55071999-12-10 08:25:07 +00002/*
3 * Mini poweroff implementation for busybox
4 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersen2cb55071999-12-10 08:25:07 +00006 *
Rob Landley2edf5262006-01-22 02:41:51 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersen2cb55071999-12-10 08:25:07 +00008 */
9
Eric Andersen2cb55071999-12-10 08:25:07 +000010#include <signal.h>
Eric Andersen02462222003-07-22 09:41:39 +000011#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 Andersen2cb55071999-12-10 08:25:07 +000018
Erik Andersene49d5ec2000-02-08 19:58:47 +000019extern int poweroff_main(int argc, char **argv)
Eric Andersen2cb55071999-12-10 08:25:07 +000020{
Eric Andersen02462222003-07-22 09:41:39 +000021 char *delay; /* delay in seconds before rebooting */
22
23 if(bb_getopt_ulflags(argc, argv, "d:", &delay)) {
24 sleep(atoi(delay));
25 }
26
Rob Landley2edf5262006-01-22 02:41:51 +000027 return ENABLE_INIT ? kill(1,SIGUSR2) : bb_shutdown_system(RB_POWER_OFF);
Eric Andersen2cb55071999-12-10 08:25:07 +000028}