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 * Copyright 2012, 2014 SAP AG. All rights reserved. |
3 * Copyright 2012, 2014 SAP AG. All rights reserved. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * |
5 * |
6 * This code is free software; you can redistribute it and/or modify it |
6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as |
7 * under the terms of the GNU General Public License version 2 only, as |
5140 |
5140 |
5141 // Run the specified command in a separate process. Return its exit value, |
5141 // Run the specified command in a separate process. Return its exit value, |
5142 // or -1 on failure (e.g. can't fork a new process). |
5142 // or -1 on failure (e.g. can't fork a new process). |
5143 // Unlike system(), this function can be called from signal handler. It |
5143 // Unlike system(), this function can be called from signal handler. It |
5144 // doesn't block SIGINT et al. |
5144 // doesn't block SIGINT et al. |
5145 int os::fork_and_exec(char* cmd) { |
5145 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) { |
5146 char * argv[4] = {"sh", "-c", cmd, NULL}; |
5146 char * argv[4] = {"sh", "-c", cmd, NULL}; |
5147 |
5147 |
5148 pid_t pid = fork(); |
5148 pid_t pid = fork(); |
5149 |
5149 |
5150 if (pid < 0) { |
5150 if (pid < 0) { |