mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8027434: "-XX:OnOutOfMemoryError" uses fork instead of vfork
Reviewed-by: dholmes, iklam
This commit is contained in:
parent
cfb6fb66c2
commit
cbe11130f5
7 changed files with 14 additions and 8 deletions
|
@ -4259,7 +4259,7 @@ extern char** environ;
|
||||||
// or -1 on failure (e.g. can't fork a new process).
|
// or -1 on failure (e.g. can't fork a new process).
|
||||||
// Unlike system(), this function can be called from signal handler. It
|
// Unlike system(), this function can be called from signal handler. It
|
||||||
// doesn't block SIGINT et al.
|
// doesn't block SIGINT et al.
|
||||||
int os::fork_and_exec(char* cmd) {
|
int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
|
||||||
char * argv[4] = {"sh", "-c", cmd, NULL};
|
char * argv[4] = {"sh", "-c", cmd, NULL};
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
|
|
|
@ -3785,7 +3785,7 @@ extern char** environ;
|
||||||
// or -1 on failure (e.g. can't fork a new process).
|
// or -1 on failure (e.g. can't fork a new process).
|
||||||
// Unlike system(), this function can be called from signal handler. It
|
// Unlike system(), this function can be called from signal handler. It
|
||||||
// doesn't block SIGINT et al.
|
// doesn't block SIGINT et al.
|
||||||
int os::fork_and_exec(char* cmd) {
|
int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
|
||||||
const char * argv[4] = {"sh", "-c", cmd, NULL};
|
const char * argv[4] = {"sh", "-c", cmd, NULL};
|
||||||
|
|
||||||
// fork() in BsdThreads/NPTL is not async-safe. It needs to run
|
// fork() in BsdThreads/NPTL is not async-safe. It needs to run
|
||||||
|
|
|
@ -5676,10 +5676,16 @@ extern char** environ;
|
||||||
// or -1 on failure (e.g. can't fork a new process).
|
// or -1 on failure (e.g. can't fork a new process).
|
||||||
// Unlike system(), this function can be called from signal handler. It
|
// Unlike system(), this function can be called from signal handler. It
|
||||||
// doesn't block SIGINT et al.
|
// doesn't block SIGINT et al.
|
||||||
int os::fork_and_exec(char* cmd) {
|
int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
|
||||||
const char * argv[4] = {"sh", "-c", cmd, NULL};
|
const char * argv[4] = {"sh", "-c", cmd, NULL};
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid_t pid ;
|
||||||
|
|
||||||
|
if (use_vfork_if_available) {
|
||||||
|
pid = vfork();
|
||||||
|
} else {
|
||||||
|
pid = fork();
|
||||||
|
}
|
||||||
|
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
// fork failed
|
// fork failed
|
||||||
|
|
|
@ -5252,7 +5252,7 @@ extern char** environ;
|
||||||
// or -1 on failure (e.g. can't fork a new process).
|
// or -1 on failure (e.g. can't fork a new process).
|
||||||
// Unlike system(), this function can be called from signal handler. It
|
// Unlike system(), this function can be called from signal handler. It
|
||||||
// doesn't block SIGINT et al.
|
// doesn't block SIGINT et al.
|
||||||
int os::fork_and_exec(char* cmd) {
|
int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
|
||||||
char * argv[4];
|
char * argv[4];
|
||||||
argv[0] = (char *)"sh";
|
argv[0] = (char *)"sh";
|
||||||
argv[1] = (char *)"-c";
|
argv[1] = (char *)"-c";
|
||||||
|
|
|
@ -5254,7 +5254,7 @@ void Parker::unpark() {
|
||||||
|
|
||||||
// Run the specified command in a separate process. Return its exit value,
|
// Run the specified command in a separate process. Return its exit value,
|
||||||
// or -1 on failure (e.g. can't create a new process).
|
// or -1 on failure (e.g. can't create a new process).
|
||||||
int os::fork_and_exec(char* cmd) {
|
int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
DWORD exit_code;
|
DWORD exit_code;
|
||||||
|
|
|
@ -543,7 +543,7 @@ class os: AllStatic {
|
||||||
static char* do_you_want_to_debug(const char* message);
|
static char* do_you_want_to_debug(const char* message);
|
||||||
|
|
||||||
// run cmd in a separate process and return its exit code; or -1 on failures
|
// run cmd in a separate process and return its exit code; or -1 on failures
|
||||||
static int fork_and_exec(char *cmd);
|
static int fork_and_exec(char *cmd, bool use_vfork_if_available = false);
|
||||||
|
|
||||||
// Call ::exit() on all platforms but Windows
|
// Call ::exit() on all platforms but Windows
|
||||||
static void exit(int num);
|
static void exit(int num);
|
||||||
|
|
|
@ -1565,7 +1565,7 @@ void VM_ReportJavaOutOfMemory::doit() {
|
||||||
#endif
|
#endif
|
||||||
tty->print_cr("\"%s\"...", cmd);
|
tty->print_cr("\"%s\"...", cmd);
|
||||||
|
|
||||||
if (os::fork_and_exec(cmd) < 0) {
|
if (os::fork_and_exec(cmd, true) < 0) {
|
||||||
tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
|
tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
|
||||||
os::strerror(errno), os::errno_name(errno), errno);
|
os::strerror(errno), os::errno_name(errno), errno);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue