Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jan 2012 22:42:43 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Guy Helmer <ghelmer@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r229937 - in head/lib: libc/gen libutil
Message-ID:  <20120110214243.GC1694@garage.freebsd.pl>
In-Reply-To: <201201101953.q0AJrPao025097@svn.freebsd.org>
References:  <201201101953.q0AJrPao025097@svn.freebsd.org>

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

--2JFBq9zoW8cOFH7v
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Jan 10, 2012 at 07:53:25PM +0000, Guy Helmer wrote:
> Author: ghelmer
> Date: Tue Jan 10 19:53:25 2012
> New Revision: 229937
> URL: http://svn.freebsd.org/changeset/base/229937
>=20
> Log:
>   Add pidfile_fileno() to obtain the file descriptor for an open
>   pidfile.
>=20
> Modified:
>   head/lib/libc/gen/getnetgrent.c
>   head/lib/libutil/libutil.h
>   head/lib/libutil/pidfile.3
>   head/lib/libutil/pidfile.c
[...]
> @@ -92,6 +94,10 @@ to start a child process.
>  The
>  .Fn pidfile_remove
>  function closes and removes a pidfile.
> +.Pp
> +The
> +.Fn pidfile_fileno
> +function returns the file descriptor for the open pid file.

In other places in this manual page we use 'pidfile' as a single word.

>  .Sh RETURN VALUES
>  The
>  .Fn pidfile_open
> @@ -105,15 +111,25 @@ If an error occurs,
>  will be set.
>  .Pp
>  .Rv -std pidfile_write pidfile_close pidfile_remove
> +.Pp
> +The
> +.Fn pidfile_fileno
> +function returns the low-level file descriptor.
> +It returns -1 and sets

I think you should also use .Va or .Li macro for -1.

> +.Va errno
> +if a NULL
> +.Vt pidfh
> +is specified, or if the pidfile is no longer open.
>  .Sh EXAMPLES
>  The following example shows in which order these functions should be use=
d.
>  Note that it is safe to pass
>  .Dv NULL
>  to
>  .Fn pidfile_write ,
> -.Fn pidfile_remove
> -and
> +.Fn pidfile_remove ,
>  .Fn pidfile_close
> +and
> +.Fn pidfile_fileno
>  functions.
>  .Bd -literal
>  struct pidfh *pfh;
> @@ -244,6 +260,16 @@ and
>  system calls and the
>  .Xr flopen 3
>  library function.
> +.Pp
> +The
> +.Fn pidfile_fileno
> +function will fail if:
> +.Bl -tag -width Er
> +.It Bq Er EDOOFUS
> +Improper function use.
> +Probably called not from the process which used
> +.Fn pidfile_open .
> +.El
>  .Sh SEE ALSO
>  .Xr open 2 ,
>  .Xr daemon 3 ,
>=20
> Modified: head/lib/libutil/pidfile.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libutil/pidfile.c	Tue Jan 10 18:43:27 2012	(r229936)
> +++ head/lib/libutil/pidfile.c	Tue Jan 10 19:53:25 2012	(r229937)
> @@ -266,3 +266,13 @@ pidfile_remove(struct pidfh *pfh)
> =20
>  	return (_pidfile_remove(pfh, 1));
>  }
> +
> +int
> +pidfile_fileno(struct pidfh *pfh)
> +{

Missing empty line here for function without local variables.

> +	if (pfh =3D=3D NULL || pfh->pf_fd =3D=3D -1) {
> +		errno =3D EDOOFUS;
> +		return (-1);
> +	}
> +	return (pfh->pf_fd);
> +}

BTW. If you are working on pidfile, it would be nice to move pidfile
structure declaration into pidfile.c. There is no need to expose it.

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

--2JFBq9zoW8cOFH7v
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk8MsNMACgkQForvXbEpPzTQ0ACg6Xs4CrH44dt3dVbL99D0M5YI
luYAn0jfLA+gwrKwkuKV+R6FqyAhOZz1
=Le5F
-----END PGP SIGNATURE-----

--2JFBq9zoW8cOFH7v--



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