commit 7d2394b33fd0442019c1d005cc01d737770bdf7c
parent 341e610005418160b4bc1fcb040531c38e994cc0
Author: leitner <leitner>
Date: Thu, 28 Feb 2002 16:34:52 +0000
add hard-reboot
Diffstat:
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/.cvsignore b/.cvsignore
@@ -2,3 +2,4 @@ minit
duh
msvc
pidfilehack
+hard-reboot
diff --git a/hard-reboot.c b/hard-reboot.c
@@ -0,0 +1,32 @@
+#include <unistd.h>
+#include <sys/reboot.h>
+
+#define ABORTMSG "hard-reboot: Aborted.\n"
+#define USAGE "Say \"hard-reboot (RESTART|HALT|POWER_OFF)\" if you really mean it.\n"
+
+void usage(void) {
+ write(2, ABORTMSG, strlen(ABORTMSG));
+ write(2, USAGE, strlen(USAGE));
+ exit(1);
+}
+
+int main(int argc, char *argv[]) {
+ if (argc!=2)
+ usage();
+
+ sync();
+ sync();
+ sync();
+ if (strcmp(argv[1], "RESTART")==0) {
+ reboot(RB_AUTOBOOT);
+ } else if (strcmp(argv[1], "HALT")==0) {
+ reboot(RB_HALT_SYSTEM);
+ } else if (strcmp(argv[1], "POWER_OFF")==0) {
+ reboot(RB_POWER_OFF);
+ } else {
+ usage();
+ }
+
+ while(1)
+ sleep(10);
+}