From owner-freebsd-hackers Thu Jun 14 8:46:13 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id AA72D37B407 for ; Thu, 14 Jun 2001 08:45:46 -0700 (PDT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (robert@fledge.pr.watson.org [192.0.2.3]) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f5EFdbf27656; Thu, 14 Jun 2001 11:39:37 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Thu, 14 Jun 2001 11:39:37 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: "Koster, K.J." Cc: Robert Withrow , Cyrille Lefevre , freebsd-hackers@FreeBSD.ORG Subject: RE: import NetBSD rc system In-Reply-To: <59063B5B4D98D311BC0D0001FA7E452205FD9CAE@l04.research.kpn.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 14 Jun 2001, Koster, K.J. wrote: > > To do some of the hierarchal start/stop at runtime stuff, you > > really need > > a stateful rc system that stores its start/stop state in > > /var/run/rc.d or > > the like. In this way, the system could track various > > activities and know > > which dependencies were already started. > > How about /var/run/{$deamon}.pid? So, one of the things I've always hated (and loved) about UNIX is the pid system. One of the problems I have with (foo).pid is that pid's are rapidly recycled, so if a daemon dies, there's no way to track that unless you're a parent process (wherein you can reliably get the exiting information via SIGCHLD and wait()). The same goes for using killall as the superuser to find and kill processes such as inetd by name: you can easily kill other things if there are user processes with the same name, etc. In my view, the only really reliable way to manage daemon processes is as the parent of the process. Unfortunately, changing to that model would be a time-consuming, compatibility-limiting process which will probably not prove feasible. Just as an example of some potential suffering: suppose your system creates and destroyes about 200 processes a second, as it's a fairly heavily loaded user and web server. Such as system takes about five and a half minutes to recycle the pid space. If your sendmail daemon has pid 238 (or some other low pid), and dies, it takes about five minutes for some other process to adopt pid 238. However, /var/run/sendmail.pid will still contain 238, as it wasn't cleaned up due to untimely death. Sending a HUP signal to 238 could do a number of nasty things, including logging you out if it's your SSH daemon :-). Using IPC to manage the daemon, in the style of newer named versions, works well as long as you know the daemon is still functional--certainly much better than signals, with the exception of forceful termination. Robert N M Watson FreeBSD Core Team, TrustedBSD Project robert@fledge.watson.org NAI Labs, Safeport Network Services To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message