]> git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/ctrlaltdel.c
Imported from util-linux-2.9i tarball.
[thirdparty/util-linux.git] / sys-utils / ctrlaltdel.c
1 /*
2 * ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination
3 * Created 4-Jul-92 by Peter Orbaek <poe@daimi.aau.dk>
4 * ftp://ftp.daimi.aau.dk/pub/linux/poe/
5 */
6
7 #include <stdio.h>
8 #include <unistd.h>
9 #include <string.h>
10 #include "linux_reboot.h"
11
12 int
13 main(int argc, char *argv[]) {
14
15 if(geteuid()) {
16 fprintf(stderr,
17 "You must be root to set the Ctrl-Alt-Del behaviour.\n");
18 exit(1);
19 }
20
21 if(argc == 2 && !strcmp("hard", argv[1])) {
22 if(my_reboot(LINUX_REBOOT_CMD_CAD_ON) < 0) {
23 perror("ctrlaltdel: reboot");
24 exit(1);
25 }
26 } else if(argc == 2 && !strcmp("soft", argv[1])) {
27 if(my_reboot(LINUX_REBOOT_CMD_CAD_OFF) < 0) {
28 perror("ctrlaltdel: reboot");
29 exit(1);
30 }
31 } else {
32 fprintf(stderr, "Usage: ctrlaltdel hard|soft\n");
33 exit(1);
34 }
35 exit(0);
36 }
37
38