Date: Fri, 28 Feb 2003 11:57:39 -0600 From: Mike Meyer <mwm-dated-1046887059.c1545d@mired.org> To: Cliff Sarginson <cls@raggedclown.net> Cc: FreeBSD Questions <FreeBSD-questions@FreeBSD.org> Subject: Re: single user mode Message-ID: <15967.41747.67024.941224@guru.mired.org> In-Reply-To: <20030227202359.GA4488@raggedclown.net> References: <20030227202359.GA4488@raggedclown.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Since nobody else stepped forward with an answer, I'll try.... In <20030227202359.GA4488@raggedclown.net>, Cliff Sarginson <cls@raggedclown.net> typed: > No I can think of kludgy ways to do this, but I want to know the way > it should be done. How can you tell from with a shell script whether you > are in single-user mode or not ? The difference between starting single-user and starting multi-user is that init just starts a shell in one case, and in the other it runs /etc/rc then deals with /etc/ttys. Shutting down to single-user shuts down the things in /etc/ttys - and anything else - then launches a shell. There doesn't appear to be a way to ask init if it's running in single-user or multi-user mode. I'd say the best way is to look for a shell process with a ppid of 1. This can be fooled by having a shell started in /etc/ttys. Looking for things to be running in multi-user mode depends on them running, which may fail during (ab)normal system operation. Might I suggest that you're not really worried about being single-user, but instead worried about some condition that is usually true in single-user mode (quiescent file systems, no network daemons, etc)? If that's the case, you'd probably be better off checking that condition than checking for single-user mode. After all, given any assumption you make about single-user mode, I can violate that assumption if I really want to. <mike -- Mike Meyer <mwm@mired.org> http://www.mired.org/consulting.html Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15967.41747.67024.941224>