JDK-8214511 : Add "POSIX_SPAWN" as valid value to jdk.lang.Process.launchMechanism on Linux
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 12
  • Submitted: 2018-11-30
  • Updated: 2019-03-08
  • Resolved: 2018-12-03
Related Reports
CSR :  
CSR :  

Make POSIX_SPAWN a valid value for -Djdk.lang.Process.launchMechanism on Linux.


It is planned to phase out support for vfork() on Linux and to switch to using posix_spawn() like all other *nixes do today already. The first step toward that is to provide POSIX_SPAWN as an addition non-default option for -Djdk.lang.Process.launchMechanism.


The implementation already exists and is in use (by default) on our other *nix platforms (BSD/MacOS, Solaris, AIX). We only have to enable that implementation for Linux as well.


When -Djdk.lang.Process.launchMechanism=POSIX_SPAWN is specified, posix_spawn() will be used instead of the default vfork() to fork off child processes. The implementation is the same which is already in use on other Unices, just extended to Linux.

What internally happens depends on the underlying libc implementation:

1) on glibc versions >= 2.4 but smaller than 2.23, posix_spawn will use a combination of vfork() and exec().
2) on glibc versions > 2.24 and on muslc, clone() is used with (CLONE_VM, CLONE_VFORK).
3) on very old glibc versions (<2.4), posix_spawn() will use fork()/exec().

[~stuefe] I believe so - [~darcy] ?

would like to backport this feature to 11u. I already have an approved fix request on the issue itself (JDK-8212128) but I am unsure how to proceeed. Does the CSR need to be backported independently from the issue?

This CSR was filed retroactively at my request. To expedite its processing, I've listed the reviewers of the changeset [~alanb] and [~rriggs] as reviewers of the CSR and change the CSR to go through the one-phase process. Will move to Approved.