Updating libutil from netbsd

This commit is contained in:
2012-09-11 18:02:49 +02:00
parent e1c1f5bfd9
commit dba3562d78
28 changed files with 1087 additions and 246 deletions

View File

@@ -1,4 +1,4 @@
.\" $NetBSD: pidfile.3,v 1.12 2010/05/05 22:05:31 wiz Exp $
.\" $NetBSD: pidfile.3,v 1.13 2011/03/29 13:55:37 jmmv Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 4, 2010
.Dd March 23, 2011
.Dt PIDFILE 3
.Os
.Sh NAME
@@ -38,34 +38,48 @@
.Sh SYNOPSIS
.In util.h
.Ft int
.Fn pidfile "const char *basename"
.Fn pidfile "const char *path"
.Sh DESCRIPTION
.Fn pidfile
writes a file containing the process ID of the program to the
creates a file containing the process ID of the caller program.
The pid file can be used as a quick reference if
the process needs to be sent a signal.
When the program exits, the pid file is removed automatically, unless
the program receives a fatal signal.
.Pp
If
.Ar path
is
.Dv NULL
or a plain basename (a name containing no directory components), the pid file
is created in the
.Pa /var/run
directory.
The file name has the form
.Pa /var/run/basename.pid .
If the
.Ar basename
argument is
The basename part is either the value of
.Ar path
if it was not
.Dv NULL ,
.Fn pidfile
will determine the program name and use that instead.
or the program name as returned by
.Xr getprogname 3
otherwise.
.Pp
The pid file can be used as a quick reference if
the process needs to be sent a signal.
When the program exits, the pid file will be removed automatically, unless
the program receives a fatal signal.
If
.Ar path
is an absolute or relative path (i.e. it contains the
.Sq /
character),
the pid file is created in the provided location.
.Pp
Note that only the first invocation of
.Fn pidfile
causes a pid file to be written; subsequent invocations have no effect
unless a new
.Ar basename
.Ar path
is supplied.
If called with a new
.Ar basename ,
.Ar path ,
.Fn pidfile
will remove the old pid file and write the new one.
.Sh RETURN VALUES
@@ -78,11 +92,13 @@ The
.Fn pidfile
function call appeared in
.Nx 1.5 .
Support for creating pid files in any arbitrary path was added in
.Nx 6.0 .
.Sh BUGS
.Fn pidfile
uses
.Xr atexit 3
to ensure the pidfile is unlinked at program exit.
to ensure the pid file is unlinked at program exit.
However, programs that use the
.Xr _exit 2
function (for example, in signal handlers)