multi/single-user mode flag?
Michael J. Young
mjy at sdti.UUCP
Thu May 19 01:21:00 AEST 1988
In article <166 at ofc.Columbia.NCR.COM> rogers at ofc.UUCP (H. L. Rogers) writes:
>In article <340 at conexch.UUCP> root at conexch.UUCP (Larry Dighera) writes:
>>The normal way for a Sys V user to determine which run level state the system
>>is in, is to do a 'who -r'.
>True, but since there is no 'standard' which specifies the system state for
>a particular run level number, a user program (application?) risks
>portability problems from vendor to vendor. Does anyone know of any
>standards work to abstract the numerical run level for Un*x systems?
I don't know of a standard way, but this should work for System V at least.
No flames for style or accuracy. Not a shar.
--------------------- cut here ---------------- cut here -------------------
# include <stdio.h>
# include <sys/types.h>
# include <utmp.h>
extern struct utmp *getutid ();
extern void utmpname ();
int main (){
struct utmp *buf; /* will hold utmp entry */
struct utmp buf2; /* dummy entry to hold search type */
/*
* look for an entry in the utmp file that is of type RUN_LVL.
* The ut_line member of this entry will contain the string
* "run-level %c", where %c is [sS1-6].
*/
buf2.ut_type = RUN_LVL;
utmpname ("/etc/utmp"); /* not really necessary */
if ((buf = getutid (&buf2)) == NULL){
perror ("rlvl: could not find RUN_LVL entry in /etc/utmp");
exit (1);
}
else {
printf ("%c\n", buf->ut_line[10]);
}
exit (0);
}
--
Mike Young - Software Development Technologies, Inc., Sudbury MA 01776
UUCP : {decvax,harvard,linus,mit-eddie}!necntc!necis!mrst!sdti!mjy
Internet : mjy%sdti.uucp at harvard.harvard.edu Tel: +1 617 443 5779
"Bill & Opus in '88" -- Consider the alternatives!
More information about the Comp.unix.wizards
mailing list