From nobody Sat Oct 18 05:14:19 2025 X-Original-To: dev-commits-src-main@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 4cpVH04rwwz6CQ8V; Sat, 18 Oct 2025 05:14:20 +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 4cpVH01ZWyz3VDy; Sat, 18 Oct 2025 05:14:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760764460; 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=88hXTM7nZYZa5VrIvvhg7Km3pK8WWAAiruXRXO/HhDg=; b=g9eMx7/eYGGGOl11UbN3Rtsm1I0+PdzDwP9U/PP7NatL+IgZwQLZQ4KEW/SL57JR5qZ4+J 6MdNL4UcI7YC+vJb1grThTUIaeSE8AmugXgBJcwXJCa1aa9XLpEjPJ2sEdiZreGMXwU6wY r3kUAshFFyWLn072PebxJOJ4y4r9owEcCPkkIesVtKwD0DmnNtxLjy9/Njjo5yA7fBeK+K FfT4MIt4O1duLW3f0faC97uCezZ7xGDtZnG+0l8/KDAsoanqaTiXTsfTVMkW/D3Gm49Wna ozQGRxkvDnC6H75uC9Z8bysf51LIOQM6HJH3ARoY102NQa1L6WprJudeTHi19g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760764460; 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=88hXTM7nZYZa5VrIvvhg7Km3pK8WWAAiruXRXO/HhDg=; b=kVZkMajfEa5sZHhbMc0Di4E12Smelahjtf71tQBFZIKFKalSYe5OPPJkYkGduYCJucZZ9h P/aRdtpjbgLC0VknifE2AvX3oSbb/eJPPbZTwZdTjkewxDOEn18aRMxCI/oLAPpA+uHqne PsHYPPBaZAnzv9vlG8fuQZsQ2rJAJ+0UcYPWhyFHEYsccRhORvcHRB0UDdcSvBaudPlsrt 4oQBI1KAcrQklYhxa0stCHWnTiQb9tgm1mwbpfnZM5v0mSXqAoZcWcyHdtUuL35KLBdOWJ Zqhf4cVuA171yUnx1q11sNFoNFzY1yQE0F3HTjUoSEjRbYH1VBZ0y2hW6dbBvw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760764460; a=rsa-sha256; cv=none; b=CCsZVrs0DeCexjNf5WTxZUxz0/5y9Do1b8WMdtK6GcC4/YcjIIxyBNPCK1r5Ew290M9p++ YqTCoS+OMh2xFpF9UaZULJCsnUyw3oL5+n16trR6Ps9800mm7BwBnjoGIvlB/lRkCwB7CQ sC4gqj0U9pb5xohwFhdGfcSPxJs6T9ywpdYYFlQemwmD3TlSpaqxf+qKqrbfDyHyiGqd6E fP4QN6w41oGTB97DioYnWPJ0+ZzWWli9lpdKK7q1KOWPagIpQJOtAXMFb7uyZC4bRlv0K6 yzaPTwv9zEej1m99LdNAymPnSj13T6EDyoCWLB5XJQpsfQS9R6YxaN6VrZdv+Q== 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 4cpVGz6xwvzBpS; Sat, 18 Oct 2025 05:14:19 +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 59I5EJeE062603; Sat, 18 Oct 2025 05:14:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59I5EJCc062600; Sat, 18 Oct 2025 05:14:19 GMT (envelope-from git) Date: Sat, 18 Oct 2025 05:14:19 GMT Message-Id: <202510180514.59I5EJCc062600@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a4981ededef3 - main - kqueue.2: document KQUEUE_CPONFORK List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: a4981ededef3c2d867ddd991905e4b65bc917a62 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a4981ededef3c2d867ddd991905e4b65bc917a62 commit a4981ededef3c2d867ddd991905e4b65bc917a62 Author: Konstantin Belousov AuthorDate: 2025-10-08 03:06:20 +0000 Commit: Konstantin Belousov CommitDate: 2025-10-18 05:12:37 +0000 kqueue.2: document KQUEUE_CPONFORK Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D52045 --- 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