From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 7 07:02:04 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 591B61065672 for ; Sat, 7 Nov 2009 07:02:04 +0000 (UTC) (envelope-from uqs@spoerlein.net) Received: from acme.spoerlein.net (cl-43.dus-01.de.sixxs.net [IPv6:2a01:198:200:2a::2]) by mx1.freebsd.org (Postfix) with ESMTP id E1E288FC18 for ; Sat, 7 Nov 2009 07:02:03 +0000 (UTC) Received: from acme.spoerlein.net (localhost.spoerlein.net [IPv6:::1]) by acme.spoerlein.net (8.14.3/8.14.3) with ESMTP id nA7722lm054257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 7 Nov 2009 08:02:02 +0100 (CET) (envelope-from uqs@spoerlein.net) Received: (from uqs@localhost) by acme.spoerlein.net (8.14.3/8.14.3/Submit) id nA7721Bs054256; Sat, 7 Nov 2009 08:02:01 +0100 (CET) (envelope-from uqs@spoerlein.net) Date: Sat, 7 Nov 2009 08:02:01 +0100 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: Jilles Tjoelker Message-ID: <20091107070201.GF34407@acme.spoerlein.net> Mail-Followup-To: Jilles Tjoelker , freebsd-hackers@freebsd.org References: <20091106222446.GB60707@stack.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091106222446.GB60707@stack.nl> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-hackers@freebsd.org Subject: Re: [patch] add pwait utility X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Nov 2009 07:02:04 -0000 On Fri, 06.11.2009 at 23:24:46 +0100, Jilles Tjoelker wrote: > I propose adding a small new utility to /usr/bin: pwait. Similar to the > Solaris utility of the same name, it waits for any process to terminate. > Some use cases I have in mind: > > * rc.subr's wait_for_pids. This is a cleaner and more efficient fix for > PR conf/132766. In the rare case that /usr is not available, the old > sleep(1) method can be used. > * interactive use, e.g. to shut down the computer when some task is done > even if the task is already running Hi Jilles, this is great! I found no sleep(3) calls in the code and it looks like the kevent stuff will make pwait exit the instant the PID is gone. This is really nice and should be used to improve wait_for_pids. I understand that shutdown duration is of zero importance for server operations, but when using FreeBSD on the desktop or laptop I often do "halt -p", just because it is seriously faster and I know the implications. A slower machine of mine is calling sleep(1) inside wait_for_pid way too often during shutdown. I'd also vote to reduce the sleep(1) call from 2s to 0.5s. Gotta do some benchmarking here ... Regards, Uli