From nobody Sat Nov 01 00:45:13 2025 X-Original-To: dev-commits-src-branches@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 4cyzf14v4rz6FWqX; Sat, 01 Nov 2025 00:45:13 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cyzf12KTGz3hH4; Sat, 01 Nov 2025 00:45:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761957913; 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=Ge0p517W7vjMWvWxIjABjbPWee0/K8zCeoScYb0GFIw=; b=QrF4hWfR8feHL6XxxgY6BlxhYtwoFm+4uInFtUD56xPEhyeSvYy4rmD3g7pYdhq3GRGnMb vPg1vVarN/jmy1pcIAz+1EQMfDm1l3XjVj0YgEtwyLfWNOfgppQ42imhJcVM6mK/EwKfzh g1eV1/Bp28dfuTk3YGKXQ1sOdwmGdfIyIv+biKGhXUA+w/daqvaEaVXcv9TwDMTQaHhuuH bj7VDsxoZTY6DEASkMqmQjYZ6ywpoCJ7uimTDea+8d4asqjizCDsv5lo5QBrh+NbwmTyFu zsUlT+0bLdNJ/TsNhtC3z5MAOIl5opIuGNZhWglP+fvEidyGnvDOFLz2pJM4vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1761957913; 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=Ge0p517W7vjMWvWxIjABjbPWee0/K8zCeoScYb0GFIw=; b=tcpTSgSE+i5xd6RgumruH05383ns/XnyBVFQIIr1A4BTiuradaz7ILZ+ABRqLYiIERI77b AUbJ9j7DwM7H3nTa2/sfEiWplWnj6XvOSAR/5p9nNdgdy3esfIsjy8XV1aHRUwjw6Zp3Yc mb7RIR7yED95+GaHIDq4eIyw2VjpqVmDDXjsmlZd9pDKIfXF7+VbIhseKPodbqMciOx3B+ qUiWhz5K4vAgiLvyfKOYpHiEQ39+If69zbww0u0AUdwTcAimKoyAj7UWH4J3x5NjDJv9f9 oOWFcx5uehLhO65yCwoud2KvtZLTCuulBpeXVgw8FUod8jRx/4zDRnlezMFSoA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1761957913; a=rsa-sha256; cv=none; b=w62w2tzN2yeMwTl06ZXPTB4A9cxRHq9vnEl5rYR6kqmK3C+VJ3/xmeGhVypU63rvdxAQWd sXmiWrX7byFu6r7QDtbFWtudwsdd+Ns0Va1UDirapS1bJArcoRXMV1Tp46LqjTDbOZGIgg WfyGTaGtnAUZTaztsMvtVZLsEMtBDclbx+aUOr5tSi3UcYjIucwCzl279hTd9dROYm2+Rp L/C6UDjrylaHpti//v4jKE5KRf4VTbVvnJFeGwhHxx6+O5fdU524uAKOFucwmqyGsaiM6e HvAW1jsesEtfCY14bHs3YskoyrZ2SXeMEVSEnYqyqCRlrCoL10IZpy5497ZKdA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cyzf11msFz1Xl; Sat, 01 Nov 2025 00:45:13 +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 5A10jDc8001015; Sat, 1 Nov 2025 00:45:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A10jD4S001012; Sat, 1 Nov 2025 00:45:13 GMT (envelope-from git) Date: Sat, 1 Nov 2025 00:45:13 GMT Message-Id: <202511010045.5A10jD4S001012@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 3aae49be3d12 - stable/15 - kqueue.2: document KQUEUE_CPONFORK List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 3aae49be3d12e30c539a42a8bec071615ccbbe35 Auto-Submitted: auto-generated The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3aae49be3d12e30c539a42a8bec071615ccbbe35 commit 3aae49be3d12e30c539a42a8bec071615ccbbe35 Author: Konstantin Belousov AuthorDate: 2025-10-08 03:06:20 +0000 Commit: Konstantin Belousov CommitDate: 2025-11-01 00:43:14 +0000 kqueue.2: document KQUEUE_CPONFORK (cherry picked from commit a4981ededef3c2d867ddd991905e4b65bc917a62) --- lib/libsys/kqueue.2 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/libsys/kqueue.2 b/lib/libsys/kqueue.2 index 96c9b0222a37..a8ebabf02cf7 100644 --- a/lib/libsys/kqueue.2 +++ b/lib/libsys/kqueue.2 @@ -97,10 +97,37 @@ system call also creates a new kernel event queue, and additionally takes a .Fa flags argument, which is a bitwise-inclusive OR of the following flags: -.Bl -tag -width "KQUEUE_CLOEXEC" +.Bl -tag -width "KQUEUE_CPONFORK" .It Dv KQUEUE_CLOEXEC The returned file descriptor is automatically closed on .Xr execve 2 +.It Dv KQUEUE_CPONFORK +When this flag is set, the created kqueue is copied into +the child process on +.Xr fork 2 +calls. +The kqueue descriptor index of the new kqueue will be inherited by the child, +that is, the numeric value of the descriptor will remain the same. +.Pp +Copying is deep, that is, each registered event in the original kqueue is +copied (and not shared) into the new kqueue. +This is contrary to how other descriptor types are handled upon +.Xr fork 2 , +where the copied file descriptor references the same file object +as the source descriptor (shallow copy). +.Pp +By default, in other words, when the flag is not set, kqueues from +the parent are not copied on fork to the child process. +The corresponding file descriptor indeces are unused in the child. +.Pp +Registered events that reference file descriptors which are not +duplicated on fork, are not copied into the new kqueue. +For instance, if the event references a file descriptor opened with the +.Dv O_CLOEXEC +flag set, it is not copied. +Similarly, if event references a kqueue opened without the +.Dv KQUEUE_CPONFORK +flag, the event is not copied. .El .Pp The