Home | History | Annotate | Download | only in shutdown
History log of /src/sbin/shutdown/shutdown.c
RevisionDateAuthorComments
 1.59  07-Dec-2024  martin As discussed on tech-userlevel: pass a "what" argument to /etc/rc.shutdown
describing why we are shutting down. This allows e.g. for UPS actions
if we are powering down.
 1.58  01-Jul-2022  kre branches: 1.58.4;
Bring shutdown(8) into the 21st century.

I found this juxtaposition in the shutdown man page kind of
interesting:

time Time is the time at which shutdown will bring the system down
and may be the word now or a future time in one of two formats:
... [2nd format:] [[[[[cc]yy]mm]dd]hh]mm, ...
If the century [cc] is not specified, it defaults to 1900 for
years [yy] between 69 and 99, ...

In that, all the "[text]" except the one "[[[[["(etc) sequence are my
interjections, The ellipses ("...") represent where I omitted irrelevant
(for here) text.

Interesting yes, bizarre also. Requiring a future time, and then
defaulting to the (long gone) 20th century (for any random year)
makes no sense at all. So I fixed it.

In another hundred years or so, anytime from 2100 onwards, but best
left at least a decade into the new century, it will need altering again.
[One could write the code to automate this adjustment, but the man
page would still need updating.] More significant changes will be
needed as the 101st century approaches (years 10000 and beyond), as
then a 2 digit century will no longer be adequate. Call me then, and
if I'm able, I'll fix it.

If someone really has a need to schedule a shutdown for sometime
between 1969 and 1999 that can still be done by explicitly giving
the "19" cc value. It is just no longer ever the default.

Otherwise, now, years 20..90 mean the 21st century (2020..2099)
(the first 2 of those are already unusable, but, IMO, that's OK)
and years 00..19 mean the 22nd century (2100..2119) (except that
00, 2100, is still technically the final year of the 21st century).

This is advance planning for near the end of the 21st century when
someone wants to schedule a shutdown for early in the following
century, and can't be bothered typing the 2 century digits.
 1.57  07-Aug-2017  uwe Use NULL instead of 0 for null pointer.
 1.56  28-Mar-2014  apb When the third arg to fwrite() is a size in bytes, then the second arg
should be 1. sizeof(*mbuf) happens to equal 1, but it's better not
to rely on that.
 1.55  27-Aug-2011  joerg branches: 1.55.2; 1.55.8;
statc + __dead
 1.54  16-Feb-2011  wiz Add -b and -vxz to usage.
 1.53  16-Feb-2011  dyoung Add flags -v, -x, and -z for verbose, debug, and silent shutdowns,
respectively, by passing flags AB_VERBOSE, AB_DEBUG, and/or AB_SILENT to
reboot(2).
 1.52  09-Jun-2010  riz branches: 1.52.2;
Remove _PATH_NOLOGIN before reboot, as well as before exit(), to prevent
a root file system which has been marked read-only in fstab from continuing
to prevent logins after reboot. From Ian D. Leroux in PR#43390.
 1.51  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.50  09-Feb-2008  dholland branches: 1.50.4; 1.50.8;
Improvements and clarifications to log messages and also to the man page.
Partially cherry-picked from or inspired by PR bin/36551 by Greg A. Woods,
plus some additional grammar/usage/clarity adjustments while I was passing
through. Any mistakes are mine.
 1.49  15-Dec-2007  perry convert __attribute__s to applicable cdefs.h macros
 1.48  10-Jul-2007  jnemeth branches: 1.48.4; 1.48.6;
PR/36626 - Jukka Salmi -- fails to compile if DEBUG is defined
 1.47  14-Mar-2007  christos - sprinkle static
- pass WARNS=4 and lint
- use size_t/time_t where appropriate
- get/setprogname()
- before executing rc.shutdown, set the real user id to 0, because shutdown
scripts may depend on it (for example su depends on being root).
- use warn instead of perror, and make sure we use the right errno.
 1.46  07-Mar-2006  jnemeth branches: 1.46.4; 1.46.6;
PR/31531: Takahiro Kambe: shutdown(8) quietly exit if execed from login shell
 1.45  27-Jun-2005  christos Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
 1.44  05-Feb-2005  xtraeme branches: 1.44.2;
Finish previous (use ANSI function declarations) this time.
 1.43  05-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.42  05-Nov-2004  dsl Add (unsigned char) cast to ctype functions
 1.41  09-Oct-2004  dsainty Comment typo: unecessary->unnecessary
 1.40  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.39  18-Oct-2002  atatat Add "-b bootstr" for shutdown to pass to reboot(8), so that shutdown
(which runs rc.shutdown, which might do stuff like, say, save your
ipnat or ipf state for restoration on reboot) can tell machines (sparc
and sun3 machines presently) how to boot.
 1.38  20-Dec-2000  cgd __CONCAT does token pasting, not string concatnation. if something like:
__CONCAT("foo","bar");
actually works to concantate strings, it's because the preprocessor expands
it into "foo""bar" as separate strings, and then ANSI string concatenation
is performed on that. It's more straightforward to just use ANSI string
concatenation directly, and newer GCCs complain (rightly) about misuse
of token pasting.
 1.37  25-Jul-2000  jdolecek backoff rev 1.36 - it's made obsolete by last rc.d changes and using
arbitrary hard time limit for /etc/rc.shutdown is not right anyway
 1.36  20-Jul-2000  jdolecek when running /etc/rc.shutdown, don't want on it until it completes
indefinitely - by default, wait maximum of 300 seconds only
the timeout is settable via new -T flag
Adjust history to mention addition of shutdown hooks and -T option on manpage

This fixes bin/10637.
 1.35  31-Oct-1999  is branches: 1.35.6;
exect->execve.
During my investigation, no reason could be found to enable tracing.
Fixes PR 7782 by Christoph Martin.
 1.34  22-Nov-1998  bad branches: 1.34.4;
testo. We want to source /etc/rc.shutdown.

Fixes PR #6474.
 1.33  29-Oct-1998  bad Run /etc/rc.shutdown when the final shutdown time has come.

Thanks to Ted Lemon for helping with my English.
 1.32  09-Oct-1998  enami Initialize the global variable `shuttime' with current time when
user requested to shutdown now, so that correct time is written in
/etc/nologin.
 1.31  09-Oct-1998  enami Add -p option in usage.
 1.30  25-Aug-1998  ross from Erik Bertelsen <erik@mediator.uni-c.dk>
{ put } { in } { lots } { of } { these } { to } { shut } { up } { egcs }
 1.29  26-Jul-1998  mycroft const poisoning.
 1.28  05-Jul-1998  mrg KNF. ensure hostname is nul-terminated
 1.27  06-Jun-1998  thorpej Add a -p option, to power down the system at the specified time.
 1.26  01-Apr-1998  kleink Need <time.h> for ctime(), time(), localtime() and mktime() prototypes.
 1.25  23-Mar-1998  fair add -D (no detach) option, per PR#4810
 1.24  21-Jan-1998  mycroft Oops; remove DEBUG.
 1.23  21-Jan-1998  mycroft Slight code rearrangement.
 1.22  20-Jan-1998  mycroft Document previous changes.
 1.21  20-Jan-1998  mycroft Recognize `-' only if it is the only argument after the time.
 1.20  20-Jan-1998  mycroft Allow `-dh'. Rearrange a bit.
 1.19  20-Jan-1998  mycroft Use err*(3) and warn*(3). Fix reading of the message from stdin.
 1.18  20-Jan-1998  mycroft Allow a century to be specified.
Don't validate the mmddhhmm values; mktime(3) does it.
 1.17  20-Jan-1998  perry make Y2K compliant and document as such.
 1.16  01-Oct-1997  enami branches: 1.16.2;
Don't delcare optind.
 1.15  16-Sep-1997  lukem resolve conflicts from lite-2 merge
 1.14  15-Sep-1997  lukem * cleanup for WARNS=1
* deprecate register
* fix .Nm usage
 1.13  10-Jul-1997  mikel cleanup for gcc -Wall
 1.12  09-Jul-1997  jtk add -d option to shutdown, as companion to reboot's -d flag (force crash dump)
 1.11  23-Jan-1997  mikel eliminate possibility that execle() will be called with one too many
arguments.
 1.10  11-Dec-1996  thorpej After passing the terminating NULL for the argv list to execle(),
don't forget the (NULL) envp.
From Lennart Augustsson <augustss@cs.chalmers.se>, PR #2737.
 1.9  18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.8  23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.7  17-Sep-1994  mycroft Merge with 4.4-Lite version.
 1.6  17-Sep-1994  mycroft Don't remove /etc/nologin if `-k' was used.
 1.5  16-Feb-1994  cgd when warning, actually warn about the correct thing!
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  16-Sep-1997  lukem imported from lite-2
 1.1.1.2  17-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.16.2.1  29-Jan-1998  mellon Pull up 1.17-1.24 (mycroft)
 1.34.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.35.6.2  25-Jul-2000  jdolecek pullup rev 1.37 from trunk (approved by thorpej):
backoff rev. 1.35.6.1 - it's made obsolete by last rc.d changes and using
arbitrary hard time limit for /etc/rc.shutdown is not right anyway
 1.35.6.1  20-Jul-2000  jdolecek pullup from trunk (approved by thorpej):
wait only finite time for completition of /etc/rc.shutdown - default is
300 seconds, that value is adjustable by new -T flag
Mention addition of shutdown hooks and -T option in HISTORY, slighly adjust
also description of -D flag and move it where it alhabetically belongs.

This fixes bin/10637.
 1.44.2.1  30-May-2009  snj Pull up following revision(s) (requested by jnemeth in ticket #2019):
sbin/shutdown/Makefile: revision 1.9
sbin/shutdown/shutdown.c: revision 1.45-1.48
Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
PR/31531: Takahiro Kambe: shutdown(8) quietly exit if execed from login shell
- sprinkle static
- pass WARNS=4 and lint
- use size_t/time_t where appropriate
- get/setprogname()
- before executing rc.shutdown, set the real user id to 0, because shutdown
scripts may depend on it (for example su depends on being root).
- use warn instead of perror, and make sure we use the right errno.
PR/36626 - Jukka Salmi -- fails to compile if DEBUG is defined
 1.46.6.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.46.4.1  17-Jul-2007  liamjfoy Pull up following revision(s) (requested by jnemeth in ticket #771):
sbin/shutdown/Makefile: revision 1.9
sbin/shutdown/shutdown.c: revision 1.47
sbin/shutdown/shutdown.c: revision 1.48
- sprinkle static
- pass WARNS=4 and lint
- use size_t/time_t where appropriate
- get/setprogname()
- before executing rc.shutdown, set the real user id to 0, because shutdown
scripts may depend on it (for example su depends on being root).
- use warn instead of perror, and make sure we use the right errno.

PR/36626 - Jukka Salmi -- fails to compile if DEBUG is defined
 1.48.6.2  18-Feb-2008  mjf Sync with HEAD.
 1.48.6.1  27-Dec-2007  mjf Sync with HEAD.
 1.48.4.2  23-Mar-2008  matt sync with HEAD
 1.48.4.1  09-Jan-2008  matt sync with HEAD
 1.50.8.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.50.4.1  28-Sep-2008  mjf Sync with HEAD.
 1.52.2.1  17-Feb-2011  bouyer Sync with HEAD
 1.55.8.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.55.2.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.58.4.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed