reboot; add command
authorAlan Cox <alan@linux.intel.com>
Tue, 19 May 2015 22:18:59 +0000 (23:18 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 19 May 2015 22:18:59 +0000 (23:18 +0100)
Applications/util/Makefile
Applications/util/reboot.c [new file with mode: 0644]

index 10af062..77d1d27 100644 (file)
@@ -68,6 +68,7 @@ SRCS  = banner.c \
        prtroot.c \
        ps.c \
        pwd.c \
+       reboot.c \
        rm.c \
        rmdir.c \
        sleep.c \
diff --git a/Applications/util/reboot.c b/Applications/util/reboot.c
new file mode 100644 (file)
index 0000000..8c36738
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ *     A simple reboot and halt
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char *argv[])
+{
+  char *p = strchr(argv[0], '/');
+  if (p)
+    p++;
+  else
+    p = argv[0];
+  if (strcmp(p, "halt") == 0)
+    uadmin(A_SHUTDOWN,0,0);
+  else
+    uadmin(A_REBOOT,0,0);
+  /* If we get here there was an error! */
+  perror(argv[0]);
+}
\ No newline at end of file