1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
5017 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
5018 jt->set_suspend_equivalent();
5019
5020 WaitForSingleObject(_ParkEvent, time);
5021 ResetEvent(_ParkEvent);
5022
5023 // If externally suspended while waiting, re-suspend
5024 if (jt->handle_special_suspend_equivalent_condition()) {
5025 jt->java_suspend_self();
5026 }
5027 }
5028 }
5029
5030 void Parker::unpark() {
5031 guarantee (_ParkEvent != NULL, "invariant") ;
5032 SetEvent(_ParkEvent);
5033 }
5034
5035 // Run the specified command in a separate process. Return its exit value,
5036 // or -1 on failure (e.g. can't create a new process).
5037 int os::fork_and_exec(char* cmd) {
5038 STARTUPINFO si;
5039 PROCESS_INFORMATION pi;
5040
5041 memset(&si, 0, sizeof(si));
5042 si.cb = sizeof(si);
5043 memset(&pi, 0, sizeof(pi));
5044 BOOL rslt = CreateProcess(NULL, // executable name - use command line
5045 cmd, // command line
5046 NULL, // process security attribute
5047 NULL, // thread security attribute
5048 TRUE, // inherits system handles
5049 0, // no creation flags
5050 NULL, // use parent's environment block
5051 NULL, // use parent's starting directory
5052 &si, // (in) startup information
5053 &pi); // (out) process information
5054
5055 if (rslt) {
5056 // Wait until child process exits.
5057 WaitForSingleObject(pi.hProcess, INFINITE);
|
1 /*
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
5017 OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */);
5018 jt->set_suspend_equivalent();
5019
5020 WaitForSingleObject(_ParkEvent, time);
5021 ResetEvent(_ParkEvent);
5022
5023 // If externally suspended while waiting, re-suspend
5024 if (jt->handle_special_suspend_equivalent_condition()) {
5025 jt->java_suspend_self();
5026 }
5027 }
5028 }
5029
5030 void Parker::unpark() {
5031 guarantee (_ParkEvent != NULL, "invariant") ;
5032 SetEvent(_ParkEvent);
5033 }
5034
5035 // Run the specified command in a separate process. Return its exit value,
5036 // or -1 on failure (e.g. can't create a new process).
5037 int os::fork_and_exec(char* cmd, bool use_vfork_if_available) {
5038 STARTUPINFO si;
5039 PROCESS_INFORMATION pi;
5040
5041 memset(&si, 0, sizeof(si));
5042 si.cb = sizeof(si);
5043 memset(&pi, 0, sizeof(pi));
5044 BOOL rslt = CreateProcess(NULL, // executable name - use command line
5045 cmd, // command line
5046 NULL, // process security attribute
5047 NULL, // thread security attribute
5048 TRUE, // inherits system handles
5049 0, // no creation flags
5050 NULL, // use parent's environment block
5051 NULL, // use parent's starting directory
5052 &si, // (in) startup information
5053 &pi); // (out) process information
5054
5055 if (rslt) {
5056 // Wait until child process exits.
5057 WaitForSingleObject(pi.hProcess, INFINITE);
|