From: naddy Date: Wed, 21 Jan 2015 19:29:52 +0000 (+0000) Subject: Use plain "-p" to specify "halt and power down", for consistency X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d6bda39e1b28c49d6a237308423ed8b5370074c4;p=openbsd Use plain "-p" to specify "halt and power down", for consistency and compatibility with other BSDs. Adapted from FreeBSD. Still permit the combination "-hp" as requested by many. ok sthen@ --- diff --git a/sbin/shutdown/shutdown.8 b/sbin/shutdown/shutdown.8 index b0629611f4d..6f6b8e2d933 100644 --- a/sbin/shutdown/shutdown.8 +++ b/sbin/shutdown/shutdown.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: shutdown.8,v 1.39 2007/11/19 08:51:49 jmc Exp $ +.\" $OpenBSD: shutdown.8,v 1.40 2015/01/21 19:29:52 naddy Exp $ .\" $NetBSD: shutdown.8,v 1.6 1995/03/18 15:01:07 cgd Exp $ .\" .\" Copyright (c) 1988, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)shutdown.8 8.1 (Berkeley) 6/5/93 .\" -.Dd $Mdocdate: November 19 2007 $ +.Dd $Mdocdate: January 21 2015 $ .Dt SHUTDOWN 8 .Os .Sh NAME @@ -58,7 +58,8 @@ The options are as follows: .Bl -tag -width Ds .It Fl d When used with -.Fl h +.Fl h , +.Fl p , or .Fl r causes system to perform a dump. @@ -93,13 +94,16 @@ does not actually halt the system, but leaves the system multi-user with logins disabled (for all but superuser). .It Fl n When used with -.Fl h +.Fl h , +.Fl p , or .Fl r prevents the normal .Xr sync 2 before stopping the system. .It Fl p +The system is powered down at the specified +.Ar time . The .Fl p flag is passed on to diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c index 73e7d72cf52..af6b4c7b22e 100644 --- a/sbin/shutdown/shutdown.c +++ b/sbin/shutdown/shutdown.c @@ -1,4 +1,4 @@ -/* $OpenBSD: shutdown.c,v 1.38 2015/01/16 06:40:01 deraadt Exp $ */ +/* $OpenBSD: shutdown.c,v 1.39 2015/01/21 19:29:52 naddy Exp $ */ /* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */ /* @@ -158,9 +158,9 @@ main(int argc, char *argv[]) "shutdown: incompatible switches -h and -r.\n"); usage(); } - if (dopower && !dohalt) { + if (doreboot && dopower) { (void)fprintf(stderr, - "shutdown: switch -p must be used with -h.\n"); + "shutdown: incompatible switches -p and -r.\n"); usage(); } getoffset(*argv++); @@ -333,7 +333,8 @@ die_you_gravy_sucking_pig_dog(void) { syslog(LOG_NOTICE, "%s by %s: %s", - doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf); + doreboot ? "reboot" : dopower ? "power-down" : dohalt ? "halt" : + "shutdown", whom, mbuf); (void)sleep(2); (void)printf("\r\nSystem shutdown time has arrived\007\007\r\n"); @@ -346,6 +347,8 @@ die_you_gravy_sucking_pig_dog(void) #ifdef DEBUG if (doreboot) (void)printf("reboot"); + else if (dopower) + (void)printf("power-down"); else if (dohalt) (void)printf("halt"); if (nosync) @@ -363,7 +366,7 @@ die_you_gravy_sucking_pig_dog(void) syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT); warn(_PATH_REBOOT); } - else if (dohalt) { + else if (dohalt || dopower) { execle(_PATH_HALT, "halt", "-l", (dopower ? "-p" : (nosync ? "-n" : (dodump ? "-d" : NULL))), (nosync ? "-n" : (dodump ? "-d" : NULL)), @@ -546,6 +549,7 @@ badtime(void) void usage(void) { - fprintf(stderr, "usage: shutdown [-] [-dfhknpr] time [warning-message ...]\n"); + fprintf(stderr, + "usage: shutdown [-] [-dfhknpr] time [warning-message ...]\n"); exit(1); }