From owner-freebsd-current@FreeBSD.ORG Tue Jan 17 13:38:10 2006 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F32F816A420 for ; Tue, 17 Jan 2006 13:38:09 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (arm132.internetdsl.tpnet.pl [83.17.198.132]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3433643D78 for ; Tue, 17 Jan 2006 13:37:57 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 0151F50A7F; Tue, 17 Jan 2006 14:37:55 +0100 (CET) Received: from localhost (pjd.wheel.pl [10.0.1.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 9210450A3E; Tue, 17 Jan 2006 14:37:48 +0100 (CET) Date: Tue, 17 Jan 2006 14:37:33 +0100 From: Pawel Jakub Dawidek To: Michael Bushkov Message-ID: <20060117133733.GD20602@garage.freebsd.pl> References: <43A009CB.2090800@rsu.ru> <20051219130928.GE63860@submonkey.net> <20051219135019.GF63860@submonkey.net> <43A6CC9E.6040109@rsu.ru> <20051219152505.GI63860@submonkey.net> <002c01c604c4$60ebe010$0100a8c0@jersey> <20051219183137.GA1103@odin.ac.hmc.edu> <43A7D4A6.6000607@rsu.ru> <20051220140927.GA1671@garage.freebsd.pl> <43A977B4.6080200@rsu.ru> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hwvH6HDNit2nSK4j" Content-Disposition: inline In-Reply-To: <43A977B4.6080200@rsu.ru> X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 7.0-CURRENT i386 User-Agent: mutt-ng/devel-r535 (FreeBSD) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-5.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.0.4 Cc: freebsd-current@FreeBSD.org, Ceri Davies Subject: Re: [PATCH] pidfile_check() possible function X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jan 2006 13:38:10 -0000 --hwvH6HDNit2nSK4j Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 21, 2005 at 06:41:40PM +0300, Michael Bushkov wrote: +> Hi! +> I've made a sample implementation of pidfile_check() function based on p= kill's takepid() function. It's interface is like this: +> int pidfile_check(const char *path, int pidfilelock, pid_t *pidptr); +>=20 +> The patch is here: +> http://rsu.ru/~bushman/libpidfile.patch +>=20 +> pidfile_check returns 0 if the pidfile owner seems to be active and (-1)= otherwise (in case of failure errno would also be set). +>=20 +> The path argument is the path of the pidfile. If pidfilelock is not 0, t= he function will attempt to lock the file to check if the pidfile owner is = currently running. If=20 +> pidptr is not NULL and pidfile owner seems to be active, it's pid will b= e placed in pidptr. Thanks for the patch. Some comments: - There is a missing close(fd) is case of flock() =3D=3D 0. - We can avoid reading when pidptr is NULL, right? Now it reads the file always, which is not always needed. I'm not going to commit the patch yet, I'll keep it in mind and commit when we can find a use for it. --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --hwvH6HDNit2nSK4j Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDzPMdForvXbEpPzQRAqQMAKCC3F+wKIRyQM+Se7ZwlHVxOBoeTgCfdBIi CWdsECTYQSVpyX4d2i6Gwjw= =90ne -----END PGP SIGNATURE----- --hwvH6HDNit2nSK4j--