Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F145463602
D51705.1777972886.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D51705.1777972886.diff
View Options
diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3
--- a/lib/libutil/pidfile.3
+++ b/lib/libutil/pidfile.3
@@ -22,14 +22,16 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd May 10, 2020
+.Dd August 2, 2025
.Dt PIDFILE 3
.Os
.Sh NAME
.Nm pidfile_open ,
.Nm pidfile_write ,
.Nm pidfile_close ,
-.Nm pidfile_remove
+.Nm pidfile_remove ,
+.Nm pidfile_fileno ,
+.Nm pidfile_signal
.Nd "library for PID files handling"
.Sh LIBRARY
.Lb libutil
@@ -45,6 +47,8 @@
.Fn pidfile_remove "struct pidfh *pfh"
.Ft int
.Fn pidfile_fileno "struct pidfh *pfh"
+.Ft int
+.Fn pidfile_signal "const char *path" "int sig" "pid_t *pidptr"
.Sh DESCRIPTION
The
.Nm pidfile
@@ -101,6 +105,26 @@
The
.Fn pidfile_fileno
function returns the file descriptor for the open pidfile.
+.Pp
+The
+.Fn pidfile_signal
+function looks for the pidfile specified by
+.Va path ,
+and if it exists and is locked, sends the signal specified by
+.Va sig
+to the PID it contains.
+If
+.Va pidptr
+is not
+.Dv NULL ,
+the PID that was found in the pidfile is stored in the location it
+points to.
+Note that calling
+.Fn pidfile_signal
+with
+.Va sig
+set to zero is an effective way to verify the existence of a pidfile
+and of the process that owns it.
.Sh RETURN VALUES
The
.Fn pidfile_open
@@ -125,6 +149,20 @@
if a NULL
.Vt pidfh
is specified, or if the pidfile is no longer open.
+.Pp
+The
+.Fn pidfile_signal
+function returns 0 if it successfully signaled a process, and an
+appropriate
+.Va errno
+value otherwise.
+Note that
+.Fn pidfile_signal
+will return
+.Dv ENOENT
+if the pidfile exists but is not locked, and that it may also return
+.Dv ESRCH
+if called just as the process is shutting down.
.Sh EXAMPLES
The following example shows in which order these functions should be used.
Note that it is safe to pass
@@ -132,7 +170,7 @@
to
.Fn pidfile_write ,
.Fn pidfile_remove ,
-.Fn pidfile_close
+.Fn pidfile_close ,
and
.Fn pidfile_fileno
functions.
@@ -281,6 +319,7 @@
.Fn pidfile_open .
.El
.Sh SEE ALSO
+.Xr kill 2 ,
.Xr open 2 ,
.Xr daemon 3 ,
.Xr flopen 3
@@ -288,11 +327,19 @@
The functions
.Fn pidfile_open ,
.Fn pidfile_write ,
-.Fn pidfile_close
+.Fn pidfile_close ,
and
.Fn pidfile_remove
first appeared in
.Fx 5.5 .
+The
+.Fn pidfile_fileno
+function was added in
+.Fx 9.1 .
+The
+.Fn pidfile_signal
+function was added in
+.Fx 14.0 .
.Sh AUTHORS
.An -nosplit
The
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 5, 9:21 AM (37 m, 41 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28561858
Default Alt Text
D51705.1777972886.diff (2 KB)
Attached To
Mode
D51705: libutil: Document pidfile_signal()
Attached
Detach File
Event Timeline
Log In to Comment