applets
arch
archival
console-tools
coreutils
debianutils
docs
e2fsprogs
editors
examples
findutils
include
init
libbb
libpwdgrp
loginutils
mailutils
miscutils
Config.in
Kbuild
adjtimex.c
bbconfig.c
beep.c
chat.c
chrt.c
crond.c
crontab.c
dc.c
devfsd.c
devmem.c
eject.c
fbsplash.c
fbsplash.cfg
flash_eraseall.c
flash_lock_unlock.c
flashcp.c
hdparm.c
inotifyd.c
ionice.c
last.c
last_fancy.c
less.c
makedevs.c
man.c
microcom.c
mountpoint.c
mt.c
raidautorun.c
readahead.c
rfkill.c
runlevel.c
rx.c
setsid.c
strings.c
taskset.c
time.c
timeout.c
ttysize.c
volname.c
wall.c
watchdog.c
modutils
networking
printutils
procps
runit
scripts
selinux
shell
sysklogd
testsuite
util-linux
.gitignore
.indent.pro
AUTHORS
Config.in
INSTALL
LICENSE
Makefile
Makefile.custom
Makefile.flags
Makefile.help
README
TEST_config_rh9
TODO
TODO_config_nommu
TODO_unicode
43 lines
935 B
C
43 lines
935 B
C
/* vi: set sw=4 ts=4: */
|
|
/*
|
|
* runlevel Prints out the previous and the current runlevel.
|
|
*
|
|
* Version: @(#)runlevel 1.20 16-Apr-1997 MvS
|
|
*
|
|
* This file is part of the sysvinit suite,
|
|
* Copyright 1991-1997 Miquel van Smoorenburg.
|
|
*
|
|
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
|
*
|
|
* initially busyboxified by Bernhard Reutner-Fischer
|
|
*/
|
|
#include "libbb.h"
|
|
#include <utmp.h>
|
|
|
|
int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|
int runlevel_main(int argc UNUSED_PARAM, char **argv)
|
|
{
|
|
struct utmp *ut;
|
|
char prev;
|
|
|
|
if (argv[1]) utmpname(argv[1]);
|
|
|
|
setutent();
|
|
while ((ut = getutent()) != NULL) {
|
|
if (ut->ut_type == RUN_LVL) {
|
|
prev = ut->ut_pid / 256;
|
|
if (prev == 0) prev = 'N';
|
|
printf("%c %c\n", prev, ut->ut_pid % 256);
|
|
if (ENABLE_FEATURE_CLEAN_UP)
|
|
endutent();
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
puts("unknown");
|
|
|
|
if (ENABLE_FEATURE_CLEAN_UP)
|
|
endutent();
|
|
return 1;
|
|
}
|