URI: 
       Refactor ctrlaltdel(8) - ubase - suckless linux base utils
  HTML git clone git://git.suckless.org/ubase
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 2d38b7cb9e4083c060b412c150823396e82ee2e7
   DIR parent 6dedded8594c5adb9d41ca71ce5145cd32da0b68
  HTML Author: FRIGN <dev@frign.de>
       Date:   Mon,  7 Sep 2015 13:02:38 +0200
       
       Refactor ctrlaltdel(8)
       
       1) Rewrite the manpage, don't just copy the util-linux manpage.
       2) Fix usage() to reflect exclusivity of flags
       3) Style changes.
       
       Diffstat:
         M ctrlaltdel.8                        |      33 ++++++++++++++++---------------
         M ctrlaltdel.c                        |      14 ++++++--------
       
       2 files changed, 23 insertions(+), 24 deletions(-)
       ---
   DIR diff --git a/ctrlaltdel.8 b/ctrlaltdel.8
       @@ -1,30 +1,31 @@
       -.Dd February 2, 2015
       +.Dd September 7, 2015
        .Dt CTRLALTDEL 8
        .Os ubase
        .Sh NAME
        .Nm ctrlaltdel
       -.Nd set the function of Ctrl-Alt-Del combination
       +.Nd toggle Ctrl-Alt-Del behaviour
        .Sh SYNOPSIS
        .Nm
       -.Op Fl hs
       +.Fl h | s
        .Sh DESCRIPTION
       -Based on examination of the
       -.Pa linux/kernel/sys.c
       -code, it is clear that there
       -are two supported functions that the Ctrl-Alt-Del sequence can perform: a
       -hard reset, which immediately reboots the computer without calling
       -.Xr sync 2
       -and without any other preparation; and a soft reset, which sends the
       -SIGINT (interrupt) signal to the init process (this is always the process
       -with PID 1). If this option is used, the
       -.Xr init 8
       -program must support this feature.
       +.Nm
       +toggles the function of Ctrl-Alt-Del based on the
       +two choices given in
       +.Pa linux/kernel/sys.c :
       +.Bl -tag -width Ds
       +.It hard reset
       +reboot the computer immediately without calling
       +.Xr sync 2 .
       +.It soft reset
       +send SIGINT to
       +.Xr init 8 .
       +.El
        .Sh OPTIONS
        .Bl -tag -width Ds
        .It Fl h
       -Perform a hard reset.
       +Set to hard reset.
        .It Fl s
       -Perform a soft reset.
       +Set to soft reset.
        .El
        .Sh SEE ALSO
        .Xr sync 2 ,
   DIR diff --git a/ctrlaltdel.c b/ctrlaltdel.c
       @@ -2,7 +2,6 @@
        #include <sys/syscall.h>
        
        #include <stdio.h>
       -#include <stdlib.h>
        #include <unistd.h>
        
        #include "reboot.h"
       @@ -11,15 +10,13 @@
        static void
        usage(void)
        {
       -        eprintf("usage: %s [-hs]\n", argv0);
       +        eprintf("usage: %s -h | -s\n", argv0);
        }
        
        int
        main(int argc, char *argv[])
        {
       -        int hflag = 0;
       -        int sflag = 0;
       -        int cmd;
       +        int hflag = 0, sflag = 0, cmd;
        
                ARGBEGIN {
                case 'h':
       @@ -32,13 +29,14 @@ main(int argc, char *argv[])
                        usage();
                } ARGEND;
        
       -        if (argc > 0 || (hflag ^ sflag) == 0)
       +        if (argc || !(hflag ^ sflag))
                        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)
       +        if (syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2,
       +                    cmd, NULL) < 0)
                        eprintf("reboot:");
       +
                return 0;
        }