mcooper@acamar.usc.edu (Michael A. Cooper) (04/20/88)
[ We are running SunOS 3.2 and 3.4 on Sun-3's. ] I've encountered some strangeness in shutting down Suns. I wrote a program called "downtime" (another "shutdown" program) that shuts a machine down. To bring the machine down to single-user I do a kill(-1, SIGTERM); According to the kill(2) man page, the -1 is suppose to broadcast the SIGTERM kill signal to all processes "except to system processes and the process sending the signal." The code in shutdown(8) that brings the machine down looks something like this: kill(-1, SIGTERM); /* terminate everyone */ sleep(5); /* & wait while they die */ ... kill(1, SIGTERM); /* sync */ kill(1, SIGTERM); /* sync */ sleep(20); ... Now the problem. I create a program to do the above as shutdown does it, start up Suntools, and run my program. All processes get the SIGTERM signal as promised (I never get to the second kill() call), but instead of getting a single-user shell, init starts a getty on the console. If I log in, I see that I am single-user (just my shell and a few other normal system processes). This only happens when I'm in Suntools and I run my shutdown program. If I'm in X or no window system at all, the machine goes right to a single-user shell. If I'm in Suntools and run the real (Sun) shutdown, it works just fine. I've even recompiled my Sun shutdown source code and it still works fine. If I try and idle init with: kill(1, SIGTSTP); which is suppose to tell init not to spawn and getty's, then kill(-1, SIGTERM); the machine hangs. If I change my program to: kill(1, SIGTERM); all processes (including my process) except system processes get SIGTERM and everything works fine, including when I'm running Suntools. This is the way the 4.3BSD shutdown does it. This way works, except I can't do anything after I do this since my own process gets killed. I've looked through the shutdown source code and I can't see anything that it does specially. (Is this some kind of Sun ploy to force people to use Sun utilities? :-)) mike Michael A. Cooper, University Computing Services, U of Southern California UUCP: {sdcrdcf, cit-vax}!oberon!mcooper BITNET: mcooper@kylara ARPA: mcooper@oberon.USC.EDU PHONE: (213) 743-2957
limes@sun.uucp (Greg Limes) (04/21/88)
In article <8558@oberon.USC.EDU>, mcooper@acamar.usc.edu (Michael A. Cooper) writes: > > [ We are running SunOS 3.2 and 3.4 on Sun-3's. ] > [lots of stuff hacked out] > If I change my program to: > > kill(1, SIGTERM); > > all processes (including my process) except system processes get > SIGTERM and everything works fine, including when I'm running > Suntools. This is the way the 4.3BSD shutdown does it. This way > works, except I can't do anything after I do this since my own process > gets killed. DISCLAIMER: While I work at SUN, I have not (yet) examined the sources to shutdown, so I do not have any idea precisely what it does. But, Mike, you can always simply catch the signal ... try signal (SIGTERM, SIG_IGN) before the kill; your program will quietly burp as it eats the SIGTERM and continues executing. > Michael A. Cooper, University Computing Services, U of Southern California > UUCP: {sdcrdcf, cit-vax}!oberon!mcooper BITNET: mcooper@kylara > ARPA: mcooper@oberon.USC.EDU PHONE: (213) 743-2957 -- Greg Limes [limes@sun.com] frames to /dev/fb I do not speak for Sun. I barely speak for myself.