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 * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
5 * - added Native Language Support
13 #include "linux_reboot.h"
16 #include "closestream.h"
18 static void __attribute__ ((__noreturn__
)) usage(FILE * out
)
20 fprintf(out
, USAGE_HEADER
);
21 fprintf(out
, _(" %s <hard|soft>\n"), program_invocation_short_name
);
22 fprintf(out
, USAGE_OPTIONS
);
23 fprintf(out
, USAGE_HELP
);
24 fprintf(out
, USAGE_VERSION
);
25 fprintf(out
, USAGE_MAN_TAIL("ctrlaltdel(8)"));
26 exit(out
== stderr
? EXIT_FAILURE
: EXIT_SUCCESS
);
29 int main(int argc
, char **argv
)
32 static const struct option longopts
[] = {
33 {"version", no_argument
, NULL
, 'V'},
34 {"help", no_argument
, NULL
, 'h'},
38 setlocale(LC_ALL
, "");
39 bindtextdomain(PACKAGE
, LOCALEDIR
);
43 while ((ch
= getopt_long(argc
, argv
, "Vh", longopts
, NULL
)) != -1)
46 printf(UTIL_LINUX_VERSION
);
56 _("You must be root to set the Ctrl-Alt-Del behaviour"));
58 if (argc
== 2 && !strcmp("hard", argv
[1])) {
59 if (my_reboot(LINUX_REBOOT_CMD_CAD_ON
) < 0)
60 err(EXIT_FAILURE
, "reboot");
61 } else if (argc
== 2 && !strcmp("soft", argv
[1])) {
62 if (my_reboot(LINUX_REBOOT_CMD_CAD_OFF
) < 0)
63 err(EXIT_FAILURE
, "reboot");