--- sbin/shutdown/shutdown.8.orig Fri Jul 4 15:35:19 1997 +++ sbin/shutdown/shutdown.8 Wed Dec 23 01:20:11 1998 @@ -40,7 +40,7 @@ .Sh SYNOPSIS .Nm shutdown .Op Fl -.Op Fl hkrn +.Op Fl hkrnx .Ar time .Op Ar warning-message ... .Sh DESCRIPTION @@ -76,6 +76,11 @@ .Xr reboot 8 at the specified .Ar time . +.It Fl x +Halt the system at the specified +.Ar time +and turn off the power supply. +This option can be used when power-control supported. .It Ar time .Ar Time is the time at which --- sbin/shutdown/shutdown.c.orig Thu Sep 3 22:11:58 1998 +++ sbin/shutdown/shutdown.c Wed Dec 23 01:20:11 1998 @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: shutdown.c,v 1.4.2.7 1998/08/12 06:35:49 charnier Exp $ + * $Id: shutdown.c,v 1.1.1.1.8.1.2.1 1998/12/22 08:27:49 nakagawa Exp $ */ #ifndef lint @@ -92,6 +92,7 @@ static time_t offset, shuttime; static int dohalt, doreboot, killflg, mbuflen; +static int dopoweroff; static char *nosync, *whom, mbuf[BUFSIZ]; void badtime __P((void)); @@ -120,7 +121,7 @@ #endif nosync = NULL; readstdin = 0; - while ((ch = getopt(argc, argv, "-hknr")) != -1) + while ((ch = getopt(argc, argv, "-hknrxp")) != -1) switch (ch) { case '-': readstdin = 1; @@ -137,6 +138,10 @@ case 'r': doreboot = 1; break; + case 'x': + case 'p': + dopoweroff = 1; + break; case '?': default: usage(); @@ -147,8 +152,8 @@ if (argc < 1) usage(); - if (doreboot && dohalt) { - warnx("incompatible switches -h and -r"); + if (doreboot + dohalt + dopoweroff > 1) { + warnx("incompatible switches -h and -r and -x."); usage(); } getoffset(*argv++); @@ -301,7 +306,7 @@ /* * play some games, just in case wall doesn't come back - * probably unnecessary, given that wall is careful. + * probably unecessary, given that wall is careful. */ if (!setjmp(alarmbuf)) { (void)signal(SIGALRM, timeout); @@ -325,7 +330,7 @@ char *empty_environ[] = { NULL }; syslog(LOG_NOTICE, "%s by %s: %s", - doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf); + doreboot ? "reboot" : dohalt ? "halt" : dopoweroff ? "power off" : "shutdown", whom, mbuf); (void)sleep(2); (void)printf("\r\nSystem shutdown time has arrived\007\007\r\n"); @@ -338,6 +343,8 @@ (void)printf("reboot"); else if (dohalt) (void)printf("halt"); + else if (dopoweroff) + (void)printf("power off"); if (nosync) (void)printf(" no sync"); (void)printf("\nkill -HUP 1\n"); @@ -354,6 +361,12 @@ syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); warn(_PATH_HALT); } + else if (dopoweroff) { + execle(_PATH_HALT, "halt", "-l", "-p", nosync, + (char *)NULL, empty_environ); + syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT); + warn(_PATH_HALT); + } (void)kill(1, SIGTERM); /* to single user */ #endif finish(0); @@ -474,12 +487,12 @@ void badtime() { - errx(1, "bad time format"); + errx(1, "bad time format."); } void usage() { - fprintf(stderr, "usage: shutdown [-hknr] shutdowntime [ message ]\n"); + fprintf(stderr, "usage: shutdown [-hknrx] shutdowntime [ message ]\n"); exit(1); }