From 833e69e83478120d29b13d6a9c2656bc1d97427d Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 11 Apr 1997 09:06:40 +0000 Subject: [PATCH] add support for a script called /etc/rc.shutdown --- sbin/reboot/reboot.8 | 11 +++++++---- sbin/reboot/reboot.c | 21 +++++++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/sbin/reboot/reboot.8 b/sbin/reboot/reboot.8 index 18471f6acec..4270813e2cb 100644 --- a/sbin/reboot/reboot.8 +++ b/sbin/reboot/reboot.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: reboot.8,v 1.2 1996/06/23 14:32:12 deraadt Exp $ +.\" $OpenBSD: reboot.8,v 1.3 1997/04/11 09:06:40 deraadt Exp $ .\" $NetBSD: reboot.8,v 1.3 1995/10/05 05:36:21 mycroft Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 @@ -52,9 +52,9 @@ The .Nm halt and .Nm reboot -utilities flush the file system cache to disk, send all running processes -a SIGTERM (and subsequently a SIGKILL) and, respectively, halt or restart -the system. +utilities flush the file system cache to disk, run the system +shutdown script, send all running processes a SIGTERM (and +subsequently a SIGKILL) and, respectively, halt or restart the system. The action is logged, including entering a shutdown record into the login accounting file. .Pp @@ -86,6 +86,9 @@ Normally, the .Xr shutdown 8 utility is used when the system needs to be halted or restarted, giving users advance warning of their impending doom. +.Sh FILES +.Pa /etc/rc.shutdown +- The script which is run at shutdown time. .Sh SEE ALSO .Xr sync 1 , .Xr utmp 5 , diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c index 99eb7889b89..91db3553480 100644 --- a/sbin/reboot/reboot.c +++ b/sbin/reboot/reboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: reboot.c,v 1.6 1997/01/17 07:12:20 millert Exp $ */ +/* $OpenBSD: reboot.c,v 1.7 1997/04/11 09:06:42 deraadt Exp $ */ /* $NetBSD: reboot.c,v 1.8 1995/10/05 05:36:22 mycroft Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)reboot.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: reboot.c,v 1.6 1997/01/17 07:12:20 millert Exp $"; +static char rcsid[] = "$OpenBSD: reboot.c,v 1.7 1997/04/11 09:06:42 deraadt Exp $"; #endif #endif /* not lint */ @@ -57,10 +57,13 @@ static char rcsid[] = "$OpenBSD: reboot.c,v 1.6 1997/01/17 07:12:20 millert Exp #include #include #include +#include void err __P((const char *fmt, ...)); void usage __P((void)); +#define _PATH_RCSHUTDOWN "/etc/rc.shutdown" + int dohalt; int @@ -147,6 +150,20 @@ main(argc, argv) /* Ignore the SIGHUP we get when our parent shell dies. */ (void)signal(SIGHUP, SIG_IGN); + if (access(_PATH_RCSHUTDOWN, R_OK) != -1) { + pid_t pid; + + switch ((pid = fork())) { + case -1: + break; + case 0: + execl(_PATH_BSHELL, "sh", _PATH_RCSHUTDOWN, NULL); + exit(1); + default: + waitpid(pid, NULL, 0); + } + } + /* Send a SIGTERM first, a chance to save the buffers. */ if (kill(-1, SIGTERM) == -1) { /* -- 2.20.1