From owner-freebsd-questions Fri Feb 28 9:57:43 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C772437B401 for ; Fri, 28 Feb 2003 09:57:41 -0800 (PST) Received: from mired.org (ip68-97-54-220.ok.ok.cox.net [68.97.54.220]) by mx1.FreeBSD.org (Postfix) with SMTP id 962F343FCB for ; Fri, 28 Feb 2003 09:57:40 -0800 (PST) (envelope-from mwm-dated-1046887059.c1545d@mired.org) Received: (qmail 69789 invoked from network); 28 Feb 2003 17:57:39 -0000 Received: from localhost.mired.org (HELO guru.mired.org) (127.0.0.1) by localhost.mired.org with SMTP; 28 Feb 2003 17:57:39 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15967.41747.67024.941224@guru.mired.org> Date: Fri, 28 Feb 2003 11:57:39 -0600 To: Cliff Sarginson Cc: FreeBSD Questions Subject: Re: single user mode In-Reply-To: <20030227202359.GA4488@raggedclown.net> References: <20030227202359.GA4488@raggedclown.net> X-Mailer: VM 7.07 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`; h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ From: Mike Meyer X-Delivery-Agent: TMDA/0.70 (Pensive) Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Since nobody else stepped forward with an answer, I'll try.... In <20030227202359.GA4488@raggedclown.net>, Cliff Sarginson 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. 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