From owner-freebsd-questions Tue Mar 23 3:57:26 1999 Delivered-To: freebsd-questions@freebsd.org Received: from alpha.comkey.com.au (alpha.comkey.com.au [203.9.152.215]) by hub.freebsd.org (Postfix) with SMTP id 2964E14CCA for ; Tue, 23 Mar 1999 03:57:11 -0800 (PST) (envelope-from gjb@comkey.com.au) Received: (qmail 12504 invoked by uid 1001); 23 Mar 1999 11:54:52 -0000 Message-ID: <19990323115452.12503.qmail@alpha.comkey.com.au> X-Posted-By: GBA-Post 1.04 06-Feb-1999 X-PGP-Fingerprint: 5A91 6942 8CEA 9DAB B95B C249 1CE1 493B 2B5A CE30 Date: Tue, 23 Mar 1999 21:54:52 +1000 From: Greg Black To: cjclark@home.com Cc: freebsd-questions@FreeBSD.ORG (FreeBSD Questions) Subject: Re: Process Checking References: <199903230637.BAA10035@cc942873-a.ewndsr1.nj.home.com> In-reply-to: <199903230637.BAA10035@cc942873-a.ewndsr1.nj.home.com> of Tue, 23 Mar 1999 01:37:19 EST Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Is there a more reliable and graceful way to check if a process, > identified by pid, is still alive? The standard way to do this from a shell script is: kill -0 $pid || restart_daemon There's a small risk that the pid has been re-cycled and is in use by some other process, but that's a race that you have to manage in any other solution anyway. Obviously, there's also a trivial C idiom for this, but I think you wanted something for a script. There are much better methods if you have source to the flaky daemon, but I'll leave them as an exercise with the atexit(3) or flock(2) man pages. -- Greg Black To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message