-.\" $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
.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
.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 ,
-/* $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 $ */
/*
#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 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <paths.h>
void err __P((const char *fmt, ...));
void usage __P((void));
+#define _PATH_RCSHUTDOWN "/etc/rc.shutdown"
+
int dohalt;
int
/* 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) {
/*