aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2016-08-29 19:33:07 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2016-08-29 19:33:07 +0000
commit7c39d98bd366d6b05df57483249d01feeb0aecfc (patch)
tree08450e7bfffaa37e8ff05dd6fc3eaf6e522dd834
parent47d6e5cb8697fad06e44f07c74524cdd68c038ef (diff)
Notes
-rw-r--r--lib/libc/sys/ptrace.224
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
index 48802f42457e8..f444fbdd2ebd2 100644
--- a/lib/libc/sys/ptrace.2
+++ b/lib/libc/sys/ptrace.2
@@ -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