From 8a76b19ecdba785437d8352a494429723ee405b8 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Mon, 6 May 2013 16:14:41 +1000 Subject: [PATCH] clone.2, execve.2: Document interaction of execve(2) with CLONE_FILES This patch the fact that a successful execve(2) in a process that is sharing a file descriptor table results in unsharing the table. I discovered this through testing and verified it by source inspection - there is a call to unshare_files() early in do_execve_common(). Signed-off-by: Michael Kerrisk --- man2/clone.2 | 3 +++ man2/execve.2 | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/man2/clone.2 b/man2/clone.2 index 707b3769a..732d85864 100644 --- a/man2/clone.2 +++ b/man2/clone.2 @@ -203,6 +203,9 @@ or changes its associated flags (using the .BR fcntl (2) .B F_SETFD operation), the other process is also affected. +If a process sharing a file descriptor table calls +.BR execve (2), +its file descriptor table is duplicated (unshared). If .B CLONE_FILES diff --git a/man2/execve.2 b/man2/execve.2 index 005171c04..83a17e4a8 100644 --- a/man2/execve.2 +++ b/man2/execve.2 @@ -202,6 +202,11 @@ The termination signal is reset to .B SIGCHLD (see .BR clone (2)). +.IP * +The file descriptor table is unshared, undoing the effect of the +.B CLONE_FILES +flag of +.BR clone (2). .PP Note the following further points: .IP * 3