Skip to content

Commit 381d229

Browse files
committed
[GR-66092] Only set jdk.lang.Process.launchMechanism if not specified
PullRequest: graal/22407
2 parents 04d3a7e + 01dd05b commit 381d229

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void duringSetup(DuringSetupAccess access) {
6565
}
6666

6767
final class PosixNativeLibrarySupport extends JNIPlatformNativeLibrarySupport {
68+
public static final String PLM_PROPERTY_NAME = "jdk.lang.Process.launchMechanism";
6869

6970
@Platforms(Platform.HOSTED_ONLY.class)
7071
private PosixNativeLibrarySupport() {
@@ -98,12 +99,17 @@ public boolean initializeBuiltinLibraries() {
9899
try {
99100
loadJavaLibrary();
100101
loadNetLibrary();
101-
/*
102-
* The JDK uses posix_spawn on the Mac to launch executables. This requires a
103-
* separate process "jspawnhelper" which we don't want to have to rely on. Force the
104-
* use of FORK on Linux and Mac.
105-
*/
106-
System.setProperty("jdk.lang.Process.launchMechanism", "FORK");
102+
103+
String launchMechanism = System.getProperty(PLM_PROPERTY_NAME);
104+
105+
if (launchMechanism == null) {
106+
/*
107+
* The JDK uses posix_spawn on the Mac to launch executables. This requires a
108+
* separate process "jspawnhelper" which we don't want to have to rely on. Force
109+
* the use of FORK on Linux and Mac.
110+
*/
111+
System.setProperty(PLM_PROPERTY_NAME, "FORK");
112+
}
107113

108114
/*
109115
* Work around a bug in fork() on Darwin by eagerly calling localtime_r to make sure

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKInitializationFeature.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ public void afterRegistration(AfterRegistrationAccess access) {
260260
rci.initializeAtRunTime("java.lang.Math$RandomNumberGeneratorHolder", "Contains random seeds");
261261
rci.initializeAtRunTime("java.lang.StrictMath$RandomNumberGeneratorHolder", "Contains random seeds");
262262

263+
rci.initializeAtRunTime("java.lang.ProcessImpl", "launchMechanism and helperpath for jspawnhelper should be computed at run-time");
264+
263265
rci.initializeAtRunTime("jdk.internal.misc.InnocuousThread", "Contains a thread group INNOCUOUSTHREADGROUP.");
264266
rci.initializeAtRunTime("jdk.internal.util.StaticProperty", "Contains run time specific values.");
265267

0 commit comments

Comments
 (0)