Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jan 2006 14:37:33 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Michael Bushkov <bushman@rsu.ru>
Cc:        freebsd-current@FreeBSD.org, Ceri Davies <ceri@submonkey.net>
Subject:   Re: [PATCH] pidfile_check() possible function
Message-ID:  <20060117133733.GD20602@garage.freebsd.pl>
In-Reply-To: <43A977B4.6080200@rsu.ru>
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>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060117133733.GD20602>