This looks like basically the right approach to me, grab the RUNLEVEL environment variable, otherwise look in utmp.
It'd be nice to make that a bit more generic, I think runlevel and telinit need the same code for things?
This looks like basically the right approach to me, grab the RUNLEVEL environment variable, otherwise look in utmp.
It'd be nice to make that a bit more generic, I think runlevel and telinit need the same code for things?