8027434: "-XX:OnOutOfMemoryError" uses fork instead of vfork
Reviewed-by: dholmes, iklam
This commit is contained in:
parent
cfb6fb66c2
commit
cbe11130f5
@ -4259,7 +4259,7 @@ extern char** environ;
|
||||
// or -1 on failure (e.g. can't fork a new process).
|
||||
// Unlike system(), this function can be called from signal handler. It
|
||||
// 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};
|
||||
|
||||
pid_t pid = fork();
|
||||
|
@ -3785,7 +3785,7 @@ extern char** environ;
|
||||
// or -1 on failure (e.g. can't fork a new process).
|
||||
// Unlike system(), this function can be called from signal handler. It
|
||||
// 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};
|
||||
|
||||
// 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).
|
||||
// Unlike system(), this function can be called from signal handler. It
|
||||
// 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};
|
||||
|
||||
pid_t pid = fork();
|
||||
pid_t pid ;
|
||||
|
||||
if (use_vfork_if_available) {
|
||||
pid = vfork();
|
||||
} else {
|
||||
pid = fork();
|
||||
}
|
||||
|
||||
if (pid < 0) {
|
||||
// fork failed
|
||||
|
@ -5252,7 +5252,7 @@ extern char** environ;
|
||||
// or -1 on failure (e.g. can't fork a new process).
|
||||
// Unlike system(), this function can be called from signal handler. It
|
||||
// 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];
|
||||
argv[0] = (char *)"sh";
|
||||
argv[1] = (char *)"-c";
|
||||
|
@ -5254,7 +5254,7 @@ void Parker::unpark() {
|
||||
|
||||
// Run the specified command in a separate process. Return its exit value,
|
||||
// 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;
|
||||
PROCESS_INFORMATION pi;
|
||||
DWORD exit_code;
|
||||
|
@ -543,7 +543,7 @@ class os: AllStatic {
|
||||
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
|
||||
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
|
||||
static void exit(int num);
|
||||
|
@ -1565,7 +1565,7 @@ void VM_ReportJavaOutOfMemory::doit() {
|
||||
#endif
|
||||
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)",
|
||||
os::strerror(errno), os::errno_name(errno), errno);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user