multi/single-user mode flag?
John F. Haugh II
haugj at pigs.UUCP
Wed May 25 03:03:34 AEST 1988
In article <7798 at ncoast.UUCP>, allbery at ncoast.UUCP (Brandon S. Allbery) writes:
] As quoted from <3595 at psuvax1.psu.edu> by okunewck at 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 at rpp386.uucp :SMAILERS
"You are in a twisty little maze of UUCP connections, all alike" -- fortune
More information about the Comp.unix.wizards
mailing list