svn commit: r305022 - head/lib/libc/sys
Konstantin Belousov
kib at FreeBSD.org
Mon Aug 29 19:33:08 UTC 2016
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
More information about the svn-src-head
mailing list