--- old/src/os/aix/vm/os_aix.cpp 2019-02-21 18:56:00.163415416 +0000 +++ new/src/os/aix/vm/os_aix.cpp 2019-02-21 18:56:00.053414692 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright 2012, 2014 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -5142,7 +5142,7 @@ // 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(); --- old/src/os/bsd/vm/os_bsd.cpp 2019-02-21 18:56:00.523417787 +0000 +++ new/src/os/bsd/vm/os_bsd.cpp 2019-02-21 18:56:00.413417064 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -4716,7 +4716,7 @@ // 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 --- old/src/os/linux/vm/os_linux.cpp 2019-02-21 18:56:00.883420160 +0000 +++ new/src/os/linux/vm/os_linux.cpp 2019-02-21 18:56:00.773419435 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2019, 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 @@ -6337,10 +6337,16 @@ // 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 --- old/src/os/solaris/vm/os_solaris.cpp 2019-02-21 18:56:01.253422598 +0000 +++ new/src/os/solaris/vm/os_solaris.cpp 2019-02-21 18:56:01.143421873 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -6153,7 +6153,7 @@ // 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"; --- old/src/os/windows/vm/os_windows.cpp 2019-02-21 18:56:01.623425035 +0000 +++ new/src/os/windows/vm/os_windows.cpp 2019-02-21 18:56:01.513424311 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -5034,7 +5034,7 @@ // 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; --- old/src/share/vm/runtime/os.hpp 2019-02-21 18:56:01.993427473 +0000 +++ new/src/share/vm/runtime/os.hpp 2019-02-21 18:56:01.893426814 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -527,7 +527,7 @@ 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); // os::exit() is merged with vm_exit() // static void exit(int num); --- old/src/share/vm/utilities/vmError.cpp 2019-02-21 18:56:02.323429646 +0000 +++ new/src/share/vm/utilities/vmError.cpp 2019-02-21 18:56:02.223428988 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -1060,7 +1060,7 @@ out.print_raw (cmd); out.print_raw_cr("\" ..."); - if (os::fork_and_exec(cmd) < 0) { + if (os::fork_and_exec(cmd, true) < 0) { out.print_cr("os::fork_and_exec failed: %s (%d)", strerror(errno), errno); } }