comparison src/os/bsd/vm/os_bsd.cpp @ 9050:97d605522fcb

8027434: "-XX:OnOutOfMemoryError" uses fork instead of vfork Summary: On Linux, use vfork in case of an OOM. Reviewed-by: dholmes, iklam
author phh
date Mon, 25 Feb 2019 21:38:45 +0000
parents 65409bcab2ad
children 0f2fe7d37d8c
comparison
equal deleted inserted replaced
86:bef55546e94e 87:607218f86934
1 /* 1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
4714 4714
4715 // Run the specified command in a separate process. Return its exit value, 4715 // Run the specified command in a separate process. Return its exit value,
4716 // or -1 on failure (e.g. can't fork a new process). 4716 // or -1 on failure (e.g. can't fork a new process).
4717 // Unlike system(), this function can be called from signal handler. It 4717 // Unlike system(), this function can be called from signal handler. It
4718 // doesn't block SIGINT et al. 4718 // doesn't block SIGINT et al.
4719 int os::fork_and_exec(char* cmd) { 4719 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
4720 const char * argv[4] = {"sh", "-c", cmd, NULL}; 4720 const char * argv[4] = {"sh", "-c", cmd, NULL};
4721 4721
4722 // fork() in BsdThreads/NPTL is not async-safe. It needs to run 4722 // fork() in BsdThreads/NPTL is not async-safe. It needs to run
4723 // pthread_atfork handlers and reset pthread library. All we need is a 4723 // pthread_atfork handlers and reset pthread library. All we need is a
4724 // separate process to execve. Make a direct syscall to fork process. 4724 // separate process to execve. Make a direct syscall to fork process.