[11574] in Athena Bugs
Re: zshutdown_notify
daemon@ATHENA.MIT.EDU (jweiss@MIT.EDU)
Mon Jan 3 15:37:11 1994
From: jweiss@MIT.EDU
To: Matt Braun <mhbraun@MIT.EDU>
Cc: bugs@MIT.EDU, op@MIT.EDU, cfields@MIT.EDU, vrt@MIT.EDU
In-Reply-To: 11564 in bugs
In-Reply-To: Your message of Mon, 27 Dec 93 17:28:42 -0500.
Date: Mon, 03 Jan 94 15:37:03 EST
OK, Here are some patches to build the bsd shutdown for DECstations
and suns. The first patch was made by tlyu (I believe). The second
was made by me (encorporating the first patch). The first should be
sufficient for getting it to build on the DECstation (although you'll
probably want to get the right syslog.h, and link against the right
syslog lib. such that syslogs won't go to compat.foo. The second is
what I used to build it on the suns (SOLARIS). Note that there seems
to be an (off by one?) bug in reporting the time till shutdown, that I
may have made worse in the SOLARIS version. Ask me in person if you
really want the gory details.
This may not actually be useful, since it's been suggested that
zshutdown_notify be incorperated into the Ultrix shutdown, rather than
porting the bsd one, But I wanted to put these patches on record
anyway.
Jonathon
patch 1:
the-other-woman:/afs/sipb/project/dec-bsd/shutdown: diff -c shutdown.c /source/bsd-4.3/common/etc/shutdown/shutdown.c
*** shutdown.c Tue Feb 23 13:53:06 1993
--- /source/bsd-4.3/common/etc/shutdown/shutdown.c Tue Apr 24 17:24:14 1990
***************
*** 366,377 ****
printf("\nkill -HUP 1\n");
#else
if (doreboot) {
! execle(_PATH_REBOOT, "reboot", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT);
perror("shutdown");
}
else if (dohalt) {
! execle(_PATH_HALT, "halt", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
perror("shutdown");
}
--- 366,377 ----
printf("\nkill -HUP 1\n");
#else
if (doreboot) {
! execle(_PATH_REBOOT, "reboot", "-l", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT);
perror("shutdown");
}
else if (dohalt) {
! execle(_PATH_HALT, "halt", "-l", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
perror("shutdown");
}
patch 2:
*** shutdown.c Wed Dec 22 12:57:51 1993
--- /source/bsd-4.3/common/etc/shutdown/shutdown.c Tue Apr 24 17:24:14 1990
***************
*** 25,40 ****
static char sccsid[] = "@(#)shutdown.c 5.12 (Berkeley) 10/28/89";
#endif /* not lint */
- #ifdef SOLARIS
- #define SVR4
- #define POSIX
- #endif
-
- #ifdef SOLARIS
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/file.h>
--- 25,30 ----
***************
*** 101,112 ****
#endif
nosync = NULL;
readstdin = 0;
- #ifndef SOLARIS
while ((ch = getopt(argc, argv, "-fhknr")) != EOF)
- #else
- /* SOLARIS doesn't do fastboot (I don't think) */
- while ((ch = getopt(argc, argv, "-hknr")) != EOF)
- #endif
switch((char)ch) {
case '-':
readstdin = 1;
--- 91,97 ----
***************
*** 146,158 ****
"shutdown: incompatible switches -h and -r.\n");
usage();
}
- #ifdef SOLARIS
- if ( (!doreboot) && (!dohalt)) {
- if (chdir("/") ) perror("shutdown");
- /* we will need to be in / to exec the solaris shutdown
- * in order to drop into single user mode. */
- }
- #endif
getoffset(*argv++);
if (*argv) {
--- 131,136 ----
***************
*** 162,172 ****
break;
if (p != mbuf)
*p++ = ' ';
- #ifdef POSIX
- memcpy(p, *argv, arglen);
- #else
bcopy(*argv, p, arglen);
- #endif
p += arglen;
}
*p = '\n';
--- 140,146 ----
***************
*** 200,208 ****
#ifdef DEBUG
(void)putc('\n', stdout);
#else
- #ifndef SOLARIS
(void)setpriority(PRIO_PROCESS, 0, PRIO_MIN);
- #endif
{
int forkpid;
--- 174,180 ----
***************
*** 226,236 ****
{
/* Get rid of any dead children */
- #ifdef SVR4
- while(waitpid(0, NULL ,WNOHANG) > 0) /* empty */ ;
- #else
while(wait3(NULL, WNOHANG, NULL) > 0) /* empty */ ;
- #endif
return(0); /* make the compiler happy */
}
--- 198,204 ----
***************
*** 243,261 ****
/*
* Set signal handler to catch dying notify() processes.
*/
- #ifdef SVR4
- {
- struct sigaction sa;
-
- sa.sa_handler = grim_reaper;
- (void) sigemptyset(&sa.sa_mask);
- sa.sa_flags = SA_SIGINFO | SA_NOCLDWAIT;
- (void) sigaction(SIGCHLD, &sa, NULL);
- }
- #else
signal(SIGCHLD, grim_reaper);
! #endif
!
if (offset <= NOLOG_TIME) {
logged = 1;
nolog();
--- 211,218 ----
/*
* Set signal handler to catch dying notify() processes.
*/
signal(SIGCHLD, grim_reaper);
!
if (offset <= NOLOG_TIME) {
logged = 1;
nolog();
***************
*** 304,321 ****
int timeout();
if (!first++)
- #ifdef SVR4
- {
- struct sigaction satoo;
-
- satoo.sa_handler = timeout;
- (void) sigemptyset(&satoo.sa_mask);
- satoo.sa_flags = SA_SIGINFO;
- (void) sigaction(SIGALRM, &satoo, NULL);
- }
- #else
(void)signal(SIGALRM, timeout);
- #endif
if (!(pf = popen(_PATH_WALL, "w"))) {
syslog(LOG_ERR, "shutdown: can't find %s: %m", _PATH_WALL);
--- 261,267 ----
***************
*** 392,400 ****
timeout()
{
- #ifdef SCROD
- (void)signal(SIGALRM, timeout); /*re-register */
- #endif
longjmp(alarmbuf, 1);
}
--- 338,343 ----
***************
*** 423,446 ****
printf("\nkill -HUP 1\n");
#else
if (doreboot) {
! execle(_PATH_REBOOT, "reboot", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT);
perror("shutdown");
}
else if (dohalt) {
! execle(_PATH_HALT, "halt", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
perror("shutdown");
}
- #ifdef SOLARIS
- (void)unlink(_PATH_NOLOGIN);
- execle(_PATH_REAL, "shutdown", "-y", "-g0", "-iS", 0);
- syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REAL);
- perror("shutdown");
- #else
(void)kill(1, SIGTERM); /* to single user */
#endif
- #endif
finish();
}
--- 366,382 ----
printf("\nkill -HUP 1\n");
#else
if (doreboot) {
! execle(_PATH_REBOOT, "reboot", "-l", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT);
perror("shutdown");
}
else if (dohalt) {
! execle(_PATH_HALT, "halt", "-l", nosync, 0);
syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_HALT);
perror("shutdown");
}
(void)kill(1, SIGTERM); /* to single user */
#endif
finish();
}
***************
*** 482,493 ****
else
goto badtime;
- #ifndef SOLARIS
unsetenv("TZ"); /* OUR timezone */
lt = localtime(&now); /* [yymmdd]hhmm */
- #else
- lt = localtime(&now); /* [yymmdd]hhmm */
- #endif
year = lt->tm_year;
month = lt->tm_mon + 1;
day = lt->tm_mday;
--- 418,425 ----
***************
*** 521,531 ****
shuttime = HOURSPERDAY * shuttime + hour;
shuttime = MINSPERHOUR * shuttime + min;
shuttime *= SECSPERMIN;
- #ifndef SOLARIS
shuttime -= lt->tm_gmtoff;
- #else
- shuttime += (lt->tm_isdst ? altzone : timezone);
- #endif
if ((offset = shuttime - now) >= 0)
break;
/* FALLTHROUGH */
--- 453,459 ----
***************
*** 578,587 ****
usage()
{
- #ifndef SOLARIS
fprintf(stderr, "usage: shutdown [-fhknr] shutdowntime [ message ]\n");
- #else
- fprintf(stderr, "usage: shutdown [-hknr] shutdowntime [ message ]\n");
- #endif
exit(1);
}
--- 506,511 ----
*** pathnames.h Fri Dec 3 22:51:55 1993
--- /source/bsd-4.3/common/etc/shutdown//pathnames.h Tue Apr 24 17:24:13 1990
***************
*** 21,30 ****
#define _PATH_NOLOGIN "/etc/nologin"
#define _PATH_HALT "/etc/halt"
#define _PATH_REBOOT "/etc/reboot"
- #ifdef SOLARIS
- #define _PATH_REAL "/usr/sbin/shutdown"
- #define _PATH_WALL "/usr/sbin/wall"
- #else
#define _PATH_WALL "/bin/wall"
- #endif
#define _PATH_NOTIFY "/etc/athena/shutdown_notify"
--- 21,25 ----