ubase/ctrlaltdel.c

45 lines
683 B
C
Raw Normal View History

2014-02-07 11:35:51 -05:00
/* See LICENSE file for copyright and license details. */
#include <sys/syscall.h>
2014-06-30 14:03:41 -04:00
2014-02-07 11:35:51 -05:00
#include <stdio.h>
#include <stdlib.h>
2014-06-30 14:03:41 -04:00
#include <unistd.h>
2014-02-07 11:35:51 -05:00
#include "reboot.h"
#include "util.h"
static void
usage(void)
{
eprintf("usage: %s [-hs]\n", 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 ^ sflag) == 0)
2014-02-07 11:35:51 -05:00
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:");
2014-10-02 18:45:25 -04:00
return 0;
2014-02-07 11:35:51 -05:00
}