From owner-freebsd-current@FreeBSD.ORG Tue Dec 20 14:10:46 2005 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 0186116A422 for ; Tue, 20 Dec 2005 14:10:45 +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 8031A43D6B for ; Tue, 20 Dec 2005 14:10:30 +0000 (GMT) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 9D4CD52B3E; Tue, 20 Dec 2005 15:10:27 +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 6032A50F93; Tue, 20 Dec 2005 15:10:21 +0100 (CET) Date: Tue, 20 Dec 2005 15:09:27 +0100 From: Pawel Jakub Dawidek To: Michael Bushkov Message-ID: <20051220140927.GA1671@garage.freebsd.pl> References: <436A0C73.3010405@rsu.ru> <20051103140221.GF29387@submonkey.net> <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> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SUOF0GtieIMvvwua" Content-Disposition: inline In-Reply-To: <43A7D4A6.6000607@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: 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, 20 Dec 2005 14:10:46 -0000 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 20, 2005 at 12:53:42PM +0300, Michael Bushkov wrote: +> Hi! +> I've just had a situation, where I want to know the pid of the already r= unning daemon, but i don't want to create the pidfile in case if there is n= o daemon running. Such a=20 +> situation can occur if the daemon has some kind of controlling program. = This program should be able to know the pid of the daemon (to send a signal= , or for some logging=20 +> purposes). +> With current pidfile API I don't see an appropriate way to do it. Pidfil= e_open() call can provide us with the PID. But if there is no daemon, this = call will create the=20 +> pidfile - and we'll have to use pidfile_remove() to do the cleanup. This= behaviour doesn't seem to be appropriate. +> Is it possible to introduce some function to return the pid of the alrea= dy running daemon or (-1), for example, if no daemon exists. Possible synta= x can be: +> int pidfile_check(pid_t *pidptr); +>=20 +> What do you think about that? Maybe... This function is not enough for sure, as you need to provide file to look for pid at least. Take a look at takepid() function in usr.bin/pkill/pkill.c to see how pkill(1) is doing this. --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --SUOF0GtieIMvvwua Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (FreeBSD) iD8DBQFDqBCXForvXbEpPzQRAma3AKDwUQrq46oumKm+/haW7W7PibfhQQCghfjD NjLCrdlWLjNmrom9C2vPMb4= =t1WS -----END PGP SIGNATURE----- --SUOF0GtieIMvvwua--