From owner-svn-src-head@freebsd.org Mon Aug 29 19:33:08 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B78D0BC7A16; Mon, 29 Aug 2016 19:33:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 850012649; Mon, 29 Aug 2016 19:33:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7TJX7P0076922; Mon, 29 Aug 2016 19:33:07 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7TJX7gn076921; Mon, 29 Aug 2016 19:33:07 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201608291933.u7TJX7gn076921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 29 Aug 2016 19:33:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305022 - head/lib/libc/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2016 19:33:08 -0000 Author: kib Date: Mon Aug 29 19:33:07 2016 New Revision: 305022 URL: https://svnweb.freebsd.org/changeset/base/305022 Log: Restore the requirement of setting errno to zero before calling ptrace(2). Describe the behaviour of automatically zeroing errno as historical feature. Requested by: ache, jhb Reviewed by: ache, bjk Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/lib/libc/sys/ptrace.2 Modified: head/lib/libc/sys/ptrace.2 ============================================================================== --- head/lib/libc/sys/ptrace.2 Mon Aug 29 19:14:52 2016 (r305021) +++ head/lib/libc/sys/ptrace.2 Mon Aug 29 19:33:07 2016 (r305022) @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd August 28, 2016 +.Dd August 29, 2016 .Dt PTRACE 2 .Os .Sh NAME @@ -900,19 +900,29 @@ argument is ignored. .Pp Additionally, other machine-specific requests can exist. .Sh RETURN VALUES +Most requests return 0 on success and \-1 on error. Some requests can cause .Fn ptrace to return \-1 -as a non-error value; to disambiguate, +as a non-error value, among them are +.Dv PT_READ_I +and +.Dv PT_READ_D , +which return the value read from the process memory on success. +To disambiguate, .Va errno -is set to 0 in the libc wrapper for the -.Fn ptrace -system call and +can be set to 0 before the call and checked afterwards. +.Pp +The current .Fn ptrace -callers can reliably check +implementation always sets +.Va errno +to 0 before calling into the kernel, both for historic reasons and for +consistency with other operating systems. +It is recommended to assign zero to .Va errno -for non-zero value afterwards. +explicitly for forward compatibility. .Sh ERRORS The .Fn ptrace