[PATCH] Documentation: Update process creation documention with Linux specific notes
Peter LaDow
petela@gocougs.wsu.edu
Fri Jun 14 15:07:00 GMT 2013
Hi,
During some static analysis of some of our code, we discovered some
functional, yet non-portable use of execve. I posted to the
glibc-help list to discuss this issue
(http://sourceware.org/ml/libc-help/2013-06/msg00018.html). In this
discussion, we noted that on Linux the passing of NULL pointers to the
exec family of functions that take arrays (e.g. execve) is functional.
Indeed, the man page for execve notes that on Linux systems passing a
NULL argv, it functions as if an array with a single NULL was passed.
Yet it warns this is non-portable. After some investigation, this
same functionality exists when envp is NULL.
I've submitted a patch to linux-man to add a note about envp's special
treatment on Linux sytems. And the patch below adds similar notes to
the process section (manual/process.texi).
Thanks,
Pete
---
manual/process.texi | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/manual/process.texi b/manual/process.texi
index e962941..072a8b2 100644
--- a/manual/process.texi
+++ b/manual/process.texi
@@ -448,6 +448,14 @@ they do not have @code{FD_CLOEXEC} set). The new
process image can
reconnect these to new streams using @code{fdopen} (@pxref{Descriptors
and Streams}).
+Note that on Linux systems, the @code{exec} functions that take arrays for
+@code{argv} and @code{envp} may be @code{NULL} (i.e. @code{execv},
+@code{execve}, @code{execle}, and @code{execvp}). In these cases, a
+@code{NULL} pointer has the same effect as passing a pointer to a list
+containing a single @code{NULL} pointer. @strong{Do not take advantage of
+this misfeature!} It is non-standard and nonportable: on most other UNIX
+systems doing this will result in an error (@code{EFAULT}).
+
@node Process Completion
@section Process Completion
@cindex process completion
--
1.8.3.1
More information about the Libc-alpha
mailing list