aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-03-24 17:11:52 +0300
committerCem Keylan <cem@ckyln.com>2020-03-24 17:11:52 +0300
commitce8eaba8581ebbb56242cc2ee73c72a928e59a99 (patch)
tree0a1852fae97e02c4b21eb4c00fe4d4ac4809070f /bin
parent2c4040656293a1e969bb01216ef2b3d5c26f225c (diff)
downloadinit-ce8eaba8581ebbb56242cc2ee73c72a928e59a99.tar.gz
add simple halt utility0.7.0
Diffstat (limited to 'bin')
-rw-r--r--bin/shalt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/bin/shalt.c b/bin/shalt.c
new file mode 100644
index 0000000..924d85d
--- /dev/null
+++ b/bin/shalt.c
@@ -0,0 +1,13 @@
+#include <unistd.h>
+#include <sys/reboot.h>
+
+/* Simple halt utility */
+/* Reboot if the argument is r, Poweroff is the argument is p */
+
+int main (int argc, char *argv[]) {
+ switch ((int)argv[argc < 2 ? 0 : 1][0] + geteuid()) {
+ case 'p': reboot(RB_POWER_OFF); break;
+ case 'r': reboot(RB_AUTOBOOT); break;
+ default: return 1;
+ }; return 0;
+}