Skip to contentSkip to conversation

clone.2, execve.2: Describe interaction of execve(2) and CLONE_FILES

PATCH New Kevin Easton 1 participant 1 message Mar 28, 2013 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clone.2, execve.2: Describe interaction of execve(2) and CLONE_FILES

Hi Michael,

This very small patch against man-pages-3.50 adds a description of the way in which a shared file descriptor table, as created by the CLONE_FILES flag of clone(2), is unshared when a process calls execve(2).

It's easy to see this from the source - there's an unshare_files() call early in do_execve_common().

- Kevin

man2/clone.2 2013-03-28 21:50:04.745932956 +1100 renamed from man2/clone.2 2013-03-15 18:17:35.000000000 +1100 +3 -0
diff -urN man-pages-3.50.orig/man2/clone.2 man-pages-3.50/man2/clone.2
@@ -180,6 +180,9 @@
 .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
man2/execve.2 2013-03-28 22:02:56.793844616 +1100 renamed from man2/execve.2 2013-03-15 18:17:35.000000000 +1100 +5 -0
diff -urN man-pages-3.50.orig/man2/execve.2 man-pages-3.50/man2/execve.2
@@ -204,6 +204,11 @@
 .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
man2/clone.2 +3 -0
diff -urN man-pages-3.50.orig/man2/clone.2 man-pages-3.50/man2/clone.2
@@ -180,6 +180,9 @@
 .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
man2/execve.2 +5 -0
diff -urN man-pages-3.50.orig/man2/execve.2 man-pages-3.50/man2/execve.2
@@ -204,6 +204,11 @@
 .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