From nobody Thu Aug 14 16:03:12 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4c2qlh2XXvz64fqL; Thu, 14 Aug 2025 16:03:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c2qlh1d1Rz3KK1; Thu, 14 Aug 2025 16:03:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755187392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Db5zarU17InNt3dr408PtJmao2+QoZmCKJ/5yFL8G9o=; b=Lo3OBYXo2hrHvWCjq9vfxeI+GZyTJfx69i6p+1T7KGr4OFviWC+6xFER9xCnl6IBW69vdJ ZtdWHxI//pndYm+dbRTuQUWCJhaVkpbiOH1KIZ4E7SyK5wbPT/BoxMa68D7UII1e0r2io7 xBcNLred3/Oz0cy+d3gTxwdT26Y28VBKU4Uy+jC4CuhjmdvzSXzuk+n1JK42l0+nGnPmMZ dIwZK0POEp4+a8yexAHIGu7janQJATUmBDBPDG2VRBwc1qez16fw26mkDPCTCSG+B5C7Ma Pqtg8A042djFWEmilR9J0WJ1mEvx7pqI+EDOB+wnlEf0htozyKc85WpnL0pRjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755187392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Db5zarU17InNt3dr408PtJmao2+QoZmCKJ/5yFL8G9o=; b=Ub5isQu+ZmByNy8ut5OgSKmW2oGbWS7LfyNwK+EqDNL7IfM4rojb4v/kPOC7OTaPGnaOAu r9uwbXC9CZ4/9+8G4GulHqDQbNqxgUrUmD8ctDxFv+pHBxTl5FmoMxPK6mqi3mtUHcsONN txDWhuPXy/CDGtzV0/1UW+KApZ9OtEDshWsOiBuG653U4YeuKfbeHjkyvVJDfHhh4KQLeU 1e0q1qYX994ZqNWboy/EYsX/kEJ+/yXtIJqKiPGzmAYDqjFiy7xXck/TxmCmc+IszlTbEy NVN7Z4GVxqwsBNZ/Za89T30LYs36N3dS+iXB/6vy+mfrHoBEEjBeFKc3GLqLcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755187392; a=rsa-sha256; cv=none; b=xrMNqDQCGtiPrOkX/BVxLIQtdo826GTS3H3iD4Xu2undR/GOEho3MMvzFMBBS4Pz4kMh7Y 82HQVZOK4atK5fNtTqmylVN+8WK8a5Lh6pF1JsNRwdah9+yNOHOo7Wl1w9IXAo8cjCOAei JvIvZ/JuS/FJdv7kLOMQ6jv8XZ+vOvoiOd0GVJqNDnwoJcir6JWaSLa2oVXw6ZQD5Fjz/e PJeFVyiH9TS2cfjHvSDbqPHlJy6jKdqkJek3syO6zOp7oJHwfsKIjk5Dg/fnmKsbuydOta tjnb+HsgVdQk6Y5jY63E0qfUM+Ta7nnYwdB8xyC9zHXY9n19UfCOXi66D7hNcQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4c2qlh18HSz10pv; Thu, 14 Aug 2025 16:03:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57EG3CNY079736; Thu, 14 Aug 2025 16:03:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57EG3Cgl079733; Thu, 14 Aug 2025 16:03:12 GMT (envelope-from git) Date: Thu, 14 Aug 2025 16:03:12 GMT Message-Id: <202508141603.57EG3Cgl079733@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 4dd4999d23f7 - stable/14 - libutil: Document pidfile_signal() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 4dd4999d23f7d2a281430729fe02ddc7cb77e92b Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4dd4999d23f7d2a281430729fe02ddc7cb77e92b commit 4dd4999d23f7d2a281430729fe02ddc7cb77e92b Author: Dag-Erling Smørgrav AuthorDate: 2025-08-03 17:31:20 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-08-14 14:00:08 +0000 libutil: Document pidfile_signal() Fixes: 287451fd0192 MFC after: 1 week Reviewed by: pauamma_gundo.com, emaste Differential Revision: https://reviews.freebsd.org/D51705 (cherry picked from commit 4e6a3e7e3240a95cda1d490831aa16ed3b9bd59b) --- lib/libutil/pidfile.3 | 68 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3 index c4786736d28f..d28d5ed8eccb 100644 --- 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 @@ function closes and removes a pidfile. 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,13 @@ and sets 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. .Sh EXAMPLES The following example shows in which order these functions should be used. Note that it is safe to pass @@ -132,7 +163,7 @@ Note that it is safe to pass to .Fn pidfile_write , .Fn pidfile_remove , -.Fn pidfile_close +.Fn pidfile_close , and .Fn pidfile_fileno functions. @@ -280,7 +311,28 @@ Improper function use. Probably called not from the process which used .Fn pidfile_open . .El +.Pp +The +.Fn pidfile_signal +function will fail if: +.Bl -tag -width Er +.It Bq Er ENOENT +The pidfile does not exist, or exists but is not locked. +.It Bq Er EDOM +The pidfile contains a negative number. +.El +.Pp +The +.Fn pidfile_signal +function may also fail and return any of the +.Va errno +values specified for the +.Fn pidfile_read +function and the +.Xr kill 2 +system call. .Sh SEE ALSO +.Xr kill 2 , .Xr open 2 , .Xr daemon 3 , .Xr flopen 3 @@ -288,11 +340,19 @@ Probably called not from the process which used 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