Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Implement a "poweroff" command which is equivalent to "halt ...



details:   https://anonhg.NetBSD.org/src/rev/908ea964c36d
branches:  trunk
changeset: 485341:908ea964c36d
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Tue Apr 25 14:03:25 2000 +0000

description:
Implement a "poweroff" command which is equivalent to "halt -p",
but allows powering down the system from an exec(2) call, e.g. via
a user which has "poweroff" as login shell.

The command name is modeled after Solaris.

diffstat:

 distrib/sets/lists/base/mi |   3 ++-
 distrib/sets/lists/man/mi  |   4 +++-
 sbin/reboot/Makefile       |   8 +++++---
 sbin/reboot/reboot.8       |  24 +++++++++++++++++-------
 sbin/reboot/reboot.c       |  12 ++++++++++--
 5 files changed, 37 insertions(+), 14 deletions(-)

diffs (178 lines):

diff -r 93e7c4401bd8 -r 908ea964c36d distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Tue Apr 25 13:57:08 2000 +0000
+++ b/distrib/sets/lists/base/mi        Tue Apr 25 14:03:25 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.156 2000/04/24 22:06:50 mellon Exp $
+# $NetBSD: mi,v 1.157 2000/04/25 14:03:25 hubertf Exp $
 .
 ./altroot
 ./bin
@@ -114,6 +114,7 @@
 ./sbin/nologin
 ./sbin/ping
 ./sbin/ping6
+./sbin/poweroff
 ./sbin/raidctl
 ./sbin/rcorder
 ./sbin/rdump
diff -r 93e7c4401bd8 -r 908ea964c36d distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Tue Apr 25 13:57:08 2000 +0000
+++ b/distrib/sets/lists/man/mi Tue Apr 25 14:03:25 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.227 2000/04/25 05:38:56 mellon Exp $
+# $NetBSD: mi,v 1.228 2000/04/25 14:03:25 hubertf Exp $
 ./usr/share/info/am-utils.info
 ./usr/share/info/awk.info
 ./usr/share/info/bfd.info
@@ -849,6 +849,7 @@
 ./usr/share/man/cat8/pim6sd.0
 ./usr/share/man/cat8/ping.0
 ./usr/share/man/cat8/ping6.0
+./usr/share/man/cat8/poweroff.0
 ./usr/share/man/cat8/portmap.0
 ./usr/share/man/cat8/pppd.0
 ./usr/share/man/cat8/pppstats.0
@@ -1812,6 +1813,7 @@
 ./usr/share/man/man8/pim6sd.8
 ./usr/share/man/man8/ping.8
 ./usr/share/man/man8/ping6.8
+./usr/share/man/man8/poweroff.8
 ./usr/share/man/man8/portmap.8
 ./usr/share/man/man8/pppd.8
 ./usr/share/man/man8/pppstats.8
diff -r 93e7c4401bd8 -r 908ea964c36d sbin/reboot/Makefile
--- a/sbin/reboot/Makefile      Tue Apr 25 13:57:08 2000 +0000
+++ b/sbin/reboot/Makefile      Tue Apr 25 14:03:25 2000 +0000
@@ -1,11 +1,13 @@
-#      $NetBSD: Makefile,v 1.16 1997/09/15 12:45:55 lukem Exp $
+#      $NetBSD: Makefile,v 1.17 2000/04/25 14:03:26 hubertf Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/5/93
 
 PROG=  reboot
 DPADD= ${LIBUTIL}
 LDADD= -lutil
 MAN=   reboot.8
-MLINKS=        reboot.8 halt.8
-LINKS= ${BINDIR}/reboot ${BINDIR}/halt
+MLINKS=        reboot.8 halt.8 \
+       reboot.8 poweroff.8
+LINKS= ${BINDIR}/reboot ${BINDIR}/halt \
+       ${BINDIR}/reboot ${BINDIR}/poweroff
 
 .include <bsd.prog.mk>
diff -r 93e7c4401bd8 -r 908ea964c36d sbin/reboot/reboot.8
--- a/sbin/reboot/reboot.8      Tue Apr 25 13:57:08 2000 +0000
+++ b/sbin/reboot/reboot.8      Tue Apr 25 14:03:25 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: reboot.8,v 1.11 1999/08/19 13:43:27 simonb Exp $
+.\"    $NetBSD: reboot.8,v 1.12 2000/04/25 14:03:26 hubertf Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -33,27 +33,31 @@
 .\"
 .\"    @(#)reboot.8    8.1 (Berkeley) 6/9/93
 .\"
-.Dd January 20, 1998
+.Dd April 14, 2000
 .Dt REBOOT 8
 .Os
 .Sh NAME
 .Nm reboot ,
+.Nm poweroff ,
 .Nm halt
 .Nd
-stopping and restarting the system
+stopping, powering down and restarting the system
 .Sh SYNOPSIS
 .Nm halt
 .Op Fl dlnpq
 .Nm ""
 .Op Fl dlnq
+.Nm poweroff
+.Op Fl dlnq
 .Sh DESCRIPTION
 The
+.Nm poweroff ,
 .Nm halt
 and
 .Nm
 utilities flush the file system cache to disk, send all running processes
 a SIGTERM, wait up to 30 seconds for them to die, send a SIGKILL to the
-survivors and, respectively, halt or restart the system.
+survivors and, respectively, power down, halt or restart the system.
 The action is logged, including entering a shutdown record into the login
 accounting file and sending a message via
 .Xr syslog 3 .
@@ -86,11 +90,12 @@
 utility is used when the system needs to be halted or restarted, giving
 users advance warning of their impending doom.
 .Sh SEE ALSO
+.Xr boot 8 ,
+.Xr reboot 2 ,
 .Xr syslog 3 ,
-.Xr utmp 5 ,
-.Xr boot 8 ,
 .Xr shutdown 8 ,
-.Xr sync 8
+.Xr sync 8 ,
+.Xr utmp 5
 .Sh BUGS
 The single user shell will ignore the SIGTERM signal.
 To avoid waiting for the timeout when 
@@ -103,3 +108,8 @@
 .Nm
 command appeared in
 .At v6 .
+
+The
+.Nm poweroff
+command first appeared in
+.Nx 1.5 .
diff -r 93e7c4401bd8 -r 908ea964c36d sbin/reboot/reboot.c
--- a/sbin/reboot/reboot.c      Tue Apr 25 13:57:08 2000 +0000
+++ b/sbin/reboot/reboot.c      Tue Apr 25 14:03:25 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: reboot.c,v 1.25 2000/03/07 20:02:59 jdolecek Exp $     */
+/*     $NetBSD: reboot.c,v 1.26 2000/04/25 14:03:26 hubertf Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -44,7 +44,7 @@
 #if 0
 static char sccsid[] = "@(#)reboot.c   8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: reboot.c,v 1.25 2000/03/07 20:02:59 jdolecek Exp $");
+__RCSID("$NetBSD: reboot.c,v 1.26 2000/04/25 14:03:26 hubertf Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,6 +67,7 @@
 extern char *__progname;
 
 int dohalt;
+int dopoweroff;
 
 int
 main(argc, argv)
@@ -82,6 +83,10 @@
        if (!strcmp(__progname, "halt") || !strcmp(__progname, "-halt")) {
                dohalt = 1;
                howto = RB_HALT;
+       } else if (!strcmp(__progname, "poweroff") 
+                  || !strcmp(__progname, "-poweroff")) {
+               dopoweroff = 1;
+               howto = RB_HALT | RB_POWERDOWN;
        } else
                howto = 0;
        lflag = nflag = qflag = 0;
@@ -142,6 +147,9 @@
                if (dohalt) {
                        openlog("halt", 0, LOG_AUTH | LOG_CONS);
                        syslog(LOG_CRIT, "halted by %s", user);
+               } else if (dopoweroff) {
+                       openlog("poweroff", 0, LOG_AUTH | LOG_CONS);
+                       syslog(LOG_CRIT, "powered off by %s", user);
                } else {
                        openlog("reboot", 0, LOG_AUTH | LOG_CONS);
                        if (bootstr)



Home | Main Index | Thread Index | Old Index