Re: Introducing a poweroff(8) command

From: Giorgos Keramidas (keramida_at_ceid.upatras.gr)
Date: 08/22/04

  • Next message: Cyrille Lefevre: "Re: Introducing a poweroff(8) command"
    Date: Sun, 22 Aug 2004 17:41:29 +0300
    To: Brian Somers <brian@Awfulhak.org>, Tom Rhodes <trhodes@freebsd.org>
    
    

    On 2004-08-21 23:50, Brian Somers <brian@Awfulhak.org> wrote:
    >
    > IMHO poweroff should behave like ``shutdown -p now'' rather than
    > ``halt -p''.

    This is relatively easy too. See below :-)

    On 2004-08-22 02:06, Tom Rhodes <trhodes@freebsd.org> wrote:
    >
    > Otherwise, I'm an src/ and can approve this if Brian is ok and
    > a 1 week timeout occurres on -arch.

    If that's an offer for precommit review/approval, thanks :-)

    On 2004-08-22 09:59, Brian Somers <brian@Awfulhak.org> wrote:
    >
    > Of course the big question is whether to implement poweroff as a shell
    > script that runs shutdown or as a link to shutdown... Precidence is on
    > the side of the link, simplicity is on the side of the script.

    The good thing about implementing this as part of shutdown is that we
    don't have to duplicate the option/command-line handling in a shell
    script. It's easier to rely on the existing code for parsing and
    validating command line arguments, with something similar to the
    existing reboot.c trick:

            p = rindex(*argv, '/')) ? p + 1 : *argv;
            if (strcmp(p, "some magic name") == 0) {
                    magic_flag = 1;
            }

    Anyway. Here's a version of the poweroff command implemented as a hard
    link to shutdown(8) instead of reboot(8). It's simpler because shutdown
    doesn't have any hard-links yet, but does this look better?

    %%%
    Index: Makefile
    ===================================================================
    RCS file: /home/ncvs/src/sbin/shutdown/Makefile,v
    retrieving revision 1.8
    diff -u -r1.8 Makefile
    --- Makefile 4 Dec 2001 02:19:57 -0000 1.8
    +++ Makefile 22 Aug 2004 13:30:43 -0000
    @@ -3,6 +3,9 @@
     
     PROG= shutdown
     MAN= shutdown.8
    +MLINKS= shutdown.8 poweroff.8
    +LINKS= ${BINDIR}/shutdown ${BINDIR}/poweroff
    +
     BINOWN= root
     BINGRP= operator
     BINMODE=4550
    Index: shutdown.8
    ===================================================================
    RCS file: /home/ncvs/src/sbin/shutdown/shutdown.8,v
    retrieving revision 1.23
    diff -u -r1.23 shutdown.8
    --- shutdown.8 2 Jul 2004 21:45:05 -0000 1.23
    +++ shutdown.8 22 Aug 2004 13:12:38 -0000
    @@ -32,7 +32,8 @@
     .Dt SHUTDOWN 8
     .Os
     .Sh NAME
    -.Nm shutdown
    +.Nm shutdown ,
    +.Nm poweroff
     .Nd "close down the system at a given time"
     .Sh SYNOPSIS
     .Nm
    @@ -47,6 +48,14 @@
     .Oc
     .Ar time
     .Op Ar warning-message ...
    +.Nm poweroff
    +.Op Fl
    +.Oo
    +.Fl o
    +.Op Fl n
    +.Oc
    +.Ar time
    +.Op Ar warning-message ...
     .Sh DESCRIPTION
     The
     .Nm
    @@ -65,6 +74,9 @@
     (hardware support required)
     at the specified
     .Ar time .
    +This is the default behavior if
    +.Nm poweroff
    +is called.
     .It Fl r
     The system is rebooted at the specified
     .Ar time .
    @@ -83,6 +95,8 @@
     .Fl r
     is specified,
     .Nm
    +or
    +.Nm poweroff
     will execute
     .Xr halt 8
     or
    @@ -103,6 +117,8 @@
     .Ar Time
     is the time at which
     .Nm
    +or
    +.Nm poweroff
     will bring the system down and
     may be the word
     .Ar now
    @@ -188,3 +204,8 @@
     .Nm
     utility appeared in
     .Bx 4.0 .
    +.Pp
    +The
    +.Nm poweroff
    +utility appeared in
    +.Fx 6.0 .
    Index: shutdown.c
    ===================================================================
    RCS file: /home/ncvs/src/sbin/shutdown/shutdown.c,v
    retrieving revision 1.26
    diff -u -r1.26 shutdown.c
    --- shutdown.c 9 Apr 2004 19:58:38 -0000 1.26
    +++ shutdown.c 22 Aug 2004 13:33:39 -0000
    @@ -115,6 +115,8 @@
             if (geteuid())
                     errx(1, "NOT super-user");
     #endif
    + if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "poweroff"))
    + dopower = 1;
             nosync = NULL;
             readstdin = 0;
             while ((ch = getopt(argc, argv, "-hknopr")) != -1)
    @@ -517,6 +519,7 @@
                     warnx("%s", cp);
             (void)fprintf(stderr,
                 "usage: shutdown [-] [-h | -p | -r | -k] [-o [-n]]"
    - " time [warning-message ...]\n");
    + " time [warning-message ...]\n"
    + " poweroff [-] [-o [-n]] time [warning-message ...]\n");
             exit(1);
     }
    %%%
    _______________________________________________
    freebsd-arch@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-arch
    To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"


  • Next message: Cyrille Lefevre: "Re: Introducing a poweroff(8) command"

    Relevant Pages

    • Solaris 10 11/06 x86_64: almost impossible to shutdown the system
      ... After upgrade to 11/06 it became almost impossible to shutdown the ... I do not have console login avaiable when this ... so I can type "poweroff" from there - machine ... Single user mode also doesn't work. ...
      (comp.unix.solaris)
    • Re: how to shutdown computer?
      ... ' Use "PowerOff" for a poweroff ... ' Use "Shutdown" for a shutdown ... ' Use "Reboot" for a reboot ... iCmd = EWX_LOGOFF + EWX_FORCE ...
      (microsoft.public.windows.server.scripting)
    • Re: Shutdown from a VBS file?
      ... WMI builtin, on Win9x you will need to install the WMI core first. ... ' PowerOff as default value ... ShutDown ".", "PowerOff" ... iCmd = EWX_LOGOFF + EWX_FORCE ...
      (microsoft.public.scripting.wsh)
    • Re: shutdown wont shutdown
      ... Nothing will seem to poweroff my PC. ... > commands, ... run lilo again and then reboot. ... to shutdown and have the computer actually turn itself off. ...
      (Debian-User)
    • Re: Introducing a poweroff(8) command
      ... > retrieving revision 1.13 ... > +.Nm poweroff ... > -.Nm halt ... > utilities flush the file system cache to disk, ...
      (freebsd-arch)