8212828: (process) Provide a way for Runtime.exec to use posix_spawn on linux

Reviewed-by: alanb, rriggs
This commit is contained in:
David M Lloyd 2018-10-18 15:56:37 -05:00 committed by Thomas Stuefe
parent 0c061174b6
commit f853aebd9b
4 changed files with 11 additions and 10 deletions

View File

@ -84,7 +84,7 @@ endif
################################################################################
ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris aix), )
ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris aix linux), )
$(eval $(call SetupJdkExecutable, BUILD_JSPAWNHELPER, \
NAME := jspawnhelper, \
SRC := $(TOPDIR)/src/$(MODULE)/unix/native/jspawnhelper, \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2018, 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
@ -89,7 +89,7 @@ final class ProcessImpl extends Process {
private static enum Platform {
LINUX(LaunchMechanism.VFORK, LaunchMechanism.FORK),
LINUX(LaunchMechanism.VFORK, LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),
BSD(LaunchMechanism.POSIX_SPAWN, LaunchMechanism.FORK),

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2018, 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
@ -44,9 +44,7 @@
#include <signal.h>
#include <string.h>
#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
#include <spawn.h>
#endif
#include "childproc.h"
@ -390,7 +388,6 @@ forkChild(ChildStuff *c) {
return resultPid;
}
#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
static pid_t
spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) {
pid_t resultPid;
@ -473,7 +470,6 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath)
* via the statement below */
return resultPid;
}
#endif
/*
* Start a child process running function childProcess.
@ -489,10 +485,8 @@ startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath)
#endif
case MODE_FORK:
return forkChild(c);
#if defined(__solaris__) || defined(_ALLBSD_SOURCE) || defined(_AIX)
case MODE_POSIX_SPAWN:
return spawnChild(env, process, c, helperpath);
#endif
default:
return -1;
}

View File

@ -36,6 +36,13 @@
* @author Martin Buchholz
*/
/*
* @test
* @modules java.base/java.lang:open
* @requires (os.family == "linux")
* @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=posix_spawn Basic
*/
import java.lang.ProcessBuilder.Redirect;
import java.lang.ProcessHandle;
import static java.lang.ProcessBuilder.Redirect.*;