[hackers] [ubase] Add ctrlaltdel tool || sin

From: <git_AT_suckless.org>
Date: Fri, 07 Feb 2014 17:41:04 +0100

commit 30824954f8097195f82072b45e82c1a0bb5538b0
Author: sin <sin_AT_2f30.org>
Date: Fri Feb 7 16:35:51 2014 +0000

    Add ctrlaltdel tool

diff --git a/Makefile b/Makefile
index 1c12d07..77d650e 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -20,6 +20,7 @@ LIB = \
 SRC = \
         chvt.c \
         clear.c \
+ ctrlaltdel.c \
         df.c \
         dmesg.c \
         eject.c \
diff --git a/ctrlaltdel.c b/ctrlaltdel.c
new file mode 100644
index 0000000..3048932
--- /dev/null
+++ b/ctrlaltdel.c
_AT_@ -0,0 +1,43 @@
+/* See LICENSE file for copyright and license details. */
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "reboot.h"
+#include "util.h"
+
+static void
+usage(void)
+{
+ eprintf("usage: %s [-hs]
", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int hflag = 0;
+ int sflag = 0;
+ int cmd;
+
+ ARGBEGIN {
+ case 'h':
+ hflag = 1;
+ break;
+ case 's':
+ sflag = 1;
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+ if (argc > 0 || (hflag != 0 && sflag != 0) ||
+ (hflag == 0 && sflag == 0))
+ usage();
+
+ cmd = hflag ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF;
+
+ if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1,
+ LINUX_REBOOT_MAGIC2, cmd, NULL) < 0)
+ eprintf("reboot:");
+ return EXIT_SUCCESS;
+}
Received on Fri Feb 07 2014 - 17:41:04 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 07 2014 - 17:48:15 CET