Problems in shutting down a Sun

Michael A. Cooper mcooper at acamar.usc.edu
Wed Apr 20 09:13:04 AEST 1988


[ 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 at kylara
  ARPA: mcooper at oberon.USC.EDU              PHONE: (213) 743-2957



More information about the Comp.unix.wizards mailing list