]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man2/clone.2
pldd.1, bpf.2, chdir.2, clone.2, fanotify_init.2, fanotify_mark.2, intro.2, ipc.2...
[thirdparty/man-pages.git] / man2 / clone.2
index 4f001fa752ab072c8115953167b21300a47fdbd7..77ad1b9c296cc5b80f80b7e657aae329ea0d7292 100644 (file)
@@ -39,7 +39,7 @@
 .\" 2008-11-19, mtk, document CLONE_NEWIPC
 .\" 2008-11-19, Jens Axboe, mtk, document CLONE_IO
 .\"
-.TH CLONE 2 2017-09-15 "Linux" "Linux Programmer's Manual"
+.TH CLONE 2 2019-08-02 "Linux" "Linux Programmer's Manual"
 .SH NAME
 clone, __clone2 \- create a child process
 .SH SYNOPSIS
@@ -163,7 +163,12 @@ Store the child thread ID at the location
 in the child's memory.
 The store operation completes before
 .BR clone ()
-returns control to user space.
+returns control to user space in the child process.
+(Note that the store operation may not have completed before
+.BR clone ()
+returns in the parent process, which will be relevant if the
+.BR CLONE_VM
+flag is also employed.)
 .TP
 .BR CLONE_FILES " (since Linux 2.0)"
 If
@@ -191,8 +196,9 @@ or change file descriptor flags,
 performed by either the calling
 process or the child process do not affect the other process.
 Note, however,
-that the duplicated file descriptors in the child refer to the same open file
-descriptions as the corresponding file descriptors in the calling process,
+that the duplicated file descriptors in the child refer to the same
+open file descriptions as the corresponding file descriptors
+in the calling process,
 and thus share file offsets and file status flags (see
 .BR open (2)).
 .TP
@@ -281,7 +287,7 @@ the calling process.
 This flag is intended for the implementation of containers.
 .IP
 An IPC namespace provides an isolated view of System\ V IPC objects (see
-.BR svipc (7))
+.BR sysvipc (7))
 and (since Linux 2.6.30)
 .\" commit 7eafd7c74c3f2e67c27621b987b28397110d643f
 .\" https://lwn.net/Articles/312232/
@@ -1012,6 +1018,16 @@ was not.
 .\" (Since Linux 2.6.0-test6.)
 .TP
 .B EINVAL
+.B CLONE_THREAD
+was specified, but the current process previously called
+.BR unshare (2)
+with the
+.B CLONE_NEWPID
+flag or used
+.BR setns (2)
+to reassociate itself with a PID namespace.
+.TP
+.B EINVAL
 .\" commit e66eded8309ebf679d3d3c1f5820d1f2ca332c71
 Both
 .B CLONE_FS
@@ -1303,7 +1319,7 @@ For an example of the use of this program, see
 #include <stdlib.h>
 #include <unistd.h>
 
-#define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \\
+#define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \e
                         } while (0)
 
 static int              /* Start function for cloned child */
@@ -1320,7 +1336,7 @@ childFunc(void *arg)
 
     if (uname(&uts) == \-1)
         errExit("uname");
-    printf("uts.nodename in child:  %s\\n", uts.nodename);
+    printf("uts.nodename in child:  %s\en", uts.nodename);
 
     /* Keep the namespace open for a while, by sleeping.
        This allows some experimentation\-\-for example, another
@@ -1342,7 +1358,7 @@ main(int argc, char *argv[])
     struct utsname uts;
 
     if (argc < 2) {
-        fprintf(stderr, "Usage: %s <child\-hostname>\\n", argv[0]);
+        fprintf(stderr, "Usage: %s <child\-hostname>\en", argv[0]);
         exit(EXIT_SUCCESS);
     }
 
@@ -1359,7 +1375,7 @@ main(int argc, char *argv[])
     pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]);
     if (pid == \-1)
         errExit("clone");
-    printf("clone() returned %ld\\n", (long) pid);
+    printf("clone() returned %ld\en", (long) pid);
 
     /* Parent falls through to here */
 
@@ -1370,11 +1386,11 @@ main(int argc, char *argv[])
 
     if (uname(&uts) == \-1)
         errExit("uname");
-    printf("uts.nodename in parent: %s\\n", uts.nodename);
+    printf("uts.nodename in parent: %s\en", uts.nodename);
 
     if (waitpid(pid, NULL, 0) == \-1)    /* Wait for child */
         errExit("waitpid");
-    printf("child has terminated\\n");
+    printf("child has terminated\en");
 
     exit(EXIT_SUCCESS);
 }