From nobody Fri Jan 20 03:23:43 2023 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 4NylFr1Qvhz30vfx; Fri, 20 Jan 2023 03:23:44 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NylFr0tg4z3nf4; Fri, 20 Jan 2023 03:23:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674185024; 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=LZ7z9UR6Nv1z8upoOAy9ArYV6Fgkopy6KynjWDfhZmo=; b=PvPR/SliBKzBSHbJjNH46NsQ19Yl5RvB9/2LUMLvuHcH/dumBEgi1EkNCwtvtHD+9WdjTH IrcAZRgr6ncMAKiBZxJUDGEQKJFMcf2F4ImE5pxShPDPyM+BA1unuRXHWBKLNXFD0AHc+6 vxjd8YIrIlY0Hfk8gUI9uKTEAWAl8j4wMJxlgw2jf1EWKgBdyQRXz8zNIykv2RgPE7k8jn QhJvpuL87H0vdpkBkuRaHqxS7Sv353Fqn2vi1GQTHowpLcqcVW0HD/y7EkTkIoy3PGGKxJ 2mTcsQQk7ZMx4oe3OPvZSAbTX7mubqkBQ8dcm0ryGLNv52pvLcHYrNZHjScyRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674185024; 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=LZ7z9UR6Nv1z8upoOAy9ArYV6Fgkopy6KynjWDfhZmo=; b=LqGz0pPkGw1BQYOfBtwD4iCZT9Zpo7re2XgXEs8wis4EcXY13ukAnKZhYIqYQYvBZ9Q1+S zJsNfYfgReARfdyJ9UaD/nrxbt7shFGm4ImVEvwh/yl/nmkAQoau1CbfN2W+OFeeOr6zY6 u/ESUVfNZe9zfLhjH5k51N2pgnRl1lTsSLSo7/2tn9Ia+gGHx5tYrLkcKefSx55k/acRkR +cgya30fsnF0YMHdTM33LedYHH59pzEYVToUpu+zdF4M3BRvTWIgYt44zexMAdn220MOEc tc43CWnpT7lSvE+Hu+xnUQSAAsG1ls9f3nA3Z6rR7ZDFy+A4dun02FaFTfimOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674185024; a=rsa-sha256; cv=none; b=jSXZhZsYOyAJJjyqTqrL9CuWuzvyqF0pHUI9+M/PMMM/Hljph7wnOjuFD0MS69WlkXTLnE w12V7gNtnGzEhmA92bLzzCTd9SgfDtvA+PZRZnezPxOGWh3g9RdbUZbv9/7BSCh6Gt/jlJ AQwYoYM72L7Lfk/mHhdYhSMUSzEkfseoW+28/ErgS5s0elLfNlKFPfCMJIHpPZRHRH8Way COPR/cw+3+CDLQaVrdsvRAX91Z9vKZhCliGQWRajR5gL1IpmC50qAOmgdvgxXe2uLtNSzy Ii14dsIoRMtLzbSUMKS3t9avTqZ+B1F2jGRIVXmFSw053ef+TcTniL+MVVaSHw== 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 4NylFq6xx4zFtq; Fri, 20 Jan 2023 03:23:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30K3NhXf042562; Fri, 20 Jan 2023 03:23:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30K3NhHP042561; Fri, 20 Jan 2023 03:23:43 GMT (envelope-from git) Date: Fri, 20 Jan 2023 03:23:43 GMT Message-Id: <202301200323.30K3NhHP042561@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: 7616d35f91cb - stable/13 - ptrace(2): explain how to select specific thread to operate on 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: 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/13 X-Git-Reftype: branch X-Git-Commit: 7616d35f91cb0d4f1a741fb385078581096f6953 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7616d35f91cb0d4f1a741fb385078581096f6953 commit 7616d35f91cb0d4f1a741fb385078581096f6953 Author: Konstantin Belousov AuthorDate: 2022-12-05 22:43:18 +0000 Commit: Konstantin Belousov CommitDate: 2023-01-20 03:20:45 +0000 ptrace(2): explain how to select specific thread to operate on Tested by: pho (cherry picked from commit 0e07241c372d7352537a4a786c96a580a721be3c) --- lib/libc/sys/ptrace.2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 74bf646efd3c..b107dcef97ae 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -122,6 +122,25 @@ Kernel drops any signals queued to the traced children, which could be either generated by not yet consumed debug events, or sent by other means, the later should not be done anyway. +.Sh SELECTING THE TARGET +The +.Fa pid +argument of the call specifies the target on which to perform +the requested operation. +For operations affecting the global process state, the process ID +is typically passed there. +Similarly, for operations affecting only a thread, the thread ID +needs to be passed. +.Pp +Still, for global operations, the ID of any thread can be used as the +target, and system will perform the request on the process owning +that thread. +If a thread operation got the process ID as +.Fa pid , +the system randomly selects a thread from among the threads owned +by the process. +For single-threaded processes there is no difference between specifying +process or thread ID as the target. .Sh DISABLING PTRACE The .Nm