Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!killer!vector!rpp386!pigs!haugj From: haugj@pigs.UUCP (John F. Haugh II) Newsgroups: comp.unix.wizards Subject: Re: multi/single-user mode flag? Summary: still needs some fixing ... Message-ID: <130@pigs.UUCP> Date: 24 May 88 17:03:34 GMT References: <3595@psuvax1.psu.edu> <7798@ncoast.UUCP> Organization: Big "D" Home for Wayward Hackers Lines: 40 In article <7798@ncoast.UUCP>, allbery@ncoast.UUCP (Brandon S. Allbery) writes: ] As quoted from <3595@psuvax1.psu.edu> by okunewck@gondor.cs.psu.edu (Phil OKunewick): ] +--------------- ] | Is there any nice way for a program to tell whether a generic ] | unix system is in single-user or multi-user mode? Two ideas here are ] | to read init's memory (not standard under different unixes) or to check ] | what processes are running (kludge). ] +--------------- ] ] who > /tmp/who$$ ] if test -s /tmp/who$$; then ] echo multiuser ] else ] echo singleuser ] fi ] rm /tmp/who$$ ] ] Who doesn't produce output in singleuser mode, since it's getty that writes ] the login records and init spawns a shell directly in singleuser mode. This ] is true under all OSes I've checked (System III/V, Xenix 2/3/5, V7). It is ] most likely true of BSD (2.x and 4.x) as well. who _does_ produce output in single user mode in one particular circumstance. go rip the cord out of the wall, and when you get back in single user mode do a who and see what you get. under sys5 you will get a list of the people who were logged in when the machine crashed. i suspect that init doesn't zero out the utmp file in xenix also. the only fixes i can think of involve removing the utmp file or changing its name every time you reboot. how to insure the commands are executed in a portable fashion is a whole different manner ... - john. -- The Beach Bum Big "D" Home for Wayward Hackers UUCP: ...!killer!rpp386!jfh jfh@rpp386.uucp :SMAILERS "You are in a twisty little maze of UUCP connections, all alike" -- fortune