7021006: (process) Remove disabled clone-exec feature
authorrriggs
Mon, 30 Mar 2015 09:49:26 -0400
changeset 29724 638809ff54f3
parent 29723 1f99eb44aa0b
child 29725 52b259320d9e
7021006: (process) Remove disabled clone-exec feature Summary: Remove clone implemention on Unix Reviewed-by: martin, alanb, dholmes
jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java
jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c
jdk/src/java.base/unix/native/libjava/childproc.c
jdk/src/java.base/unix/native/libjava/childproc.h
--- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java	Mon Mar 30 09:45:39 2015 -0400
+++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java	Mon Mar 30 09:49:26 2015 -0400
@@ -285,8 +285,6 @@
      *   1 - fork(2) and exec(2)
      *   2 - posix_spawn(3P)
      *   3 - vfork(2) and exec(2)
-     *
-     *  (4 - clone(2) and exec(2) - obsolete and currently disabled in native code)
      * </pre>
      * @param fds an array of three file descriptors.
      *        Indexes 0, 1, and 2 correspond to standard input,
--- a/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c	Mon Mar 30 09:45:39 2015 -0400
+++ b/jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c	Mon Mar 30 09:49:26 2015 -0400
@@ -97,8 +97,7 @@
  *   address space temporarily, before launching the target command.
  *
  * Based on the above analysis, we are currently using vfork() on
- * Linux and spawn() on other Unix systems, but the code to use clone()
- * and fork() remains.
+ * Linux and posix_spawn() on other Unix systems.
  */
 
 
@@ -385,39 +384,13 @@
 }
 
 /**
- * We are unusually paranoid; use of clone/vfork is
+ * We are unusually paranoid; use of vfork is
  * especially likely to tickle gcc/glibc bugs.
  */
 #ifdef __attribute_noinline__  /* See: sys/cdefs.h */
 __attribute_noinline__
 #endif
 
-#define START_CHILD_USE_CLONE 0  /* clone() currently disabled; see above. */
-
-#ifdef START_CHILD_USE_CLONE
-static pid_t
-cloneChild(ChildStuff *c) {
-#ifdef __linux__
-#define START_CHILD_CLONE_STACK_SIZE (64 * 1024)
-    /*
-     * See clone(2).
-     * Instead of worrying about which direction the stack grows, just
-     * allocate twice as much and start the stack in the middle.
-     */
-    if ((c->clone_stack = malloc(2 * START_CHILD_CLONE_STACK_SIZE)) == NULL)
-        /* errno will be set to ENOMEM */
-        return -1;
-    return clone(childProcess,
-                 c->clone_stack + START_CHILD_CLONE_STACK_SIZE,
-                 CLONE_VFORK | CLONE_VM | SIGCHLD, c);
-#else
-/* not available on Solaris / Mac */
-    assert(0);
-    return -1;
-#endif
-}
-#endif
-
 static pid_t
 vforkChild(ChildStuff *c) {
     volatile pid_t resultPid;
@@ -590,12 +563,11 @@
     c->argv = NULL;
     c->envv = NULL;
     c->pdir = NULL;
-    c->clone_stack = NULL;
 
     /* Convert prog + argBlock into a char ** argv.
      * Add one word room for expansion of argv for use by
      * execve_as_traditional_shell_script.
-     * This word is also used when using spawn mode
+     * This word is also used when using posix_spawn mode
      */
     assert(prog != NULL && argBlock != NULL);
     if ((phelperpath = getBytes(env, helperpath))   == NULL) goto Catch;
@@ -654,7 +626,7 @@
             throwIOException(env, errno, "fork failed");
             break;
           case MODE_POSIX_SPAWN:
-            throwIOException(env, errno, "spawn failed");
+            throwIOException(env, errno, "posix_spawn failed");
             break;
         }
         goto Catch;
@@ -677,8 +649,6 @@
     fds[2] = (err[0] != -1) ? err[0] : -1;
 
  Finally:
-    free(c->clone_stack);
-
     /* Always clean up the child's side of the pipes */
     closeSafely(in [0]);
     closeSafely(out[1]);
--- a/jdk/src/java.base/unix/native/libjava/childproc.c	Mon Mar 30 09:45:39 2015 -0400
+++ b/jdk/src/java.base/unix/native/libjava/childproc.c	Mon Mar 30 09:49:26 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -304,7 +304,7 @@
 }
 
 /**
- * Child process after a successful fork() or clone().
+ * Child process after a successful fork().
  * This function must not return, and must be prepared for either all
  * of its address space to be shared with its parent, or to be a copy.
  * It must not modify global variables such as "environ".
--- a/jdk/src/java.base/unix/native/libjava/childproc.h	Mon Mar 30 09:45:39 2015 -0400
+++ b/jdk/src/java.base/unix/native/libjava/childproc.h	Mon Mar 30 09:49:26 2015 -0400
@@ -101,7 +101,6 @@
     const char **envv;
     const char *pdir;
     int redirectErrorStream;
-    void *clone_stack;
 } ChildStuff;
 
 /* following used in addition when mode is SPAWN */