author | robm |
Fri, 18 Oct 2013 16:28:35 +0100 | |
changeset 21294 | 545dfa5b947e |
parent 19372 | e404c834f1cd |
permissions | -rw-r--r-- |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
1 |
/* |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
4 |
* |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
8 |
* |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
13 |
* accompanied this code). |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
14 |
* |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
18 |
* |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
21 |
* questions. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
22 |
*/ |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
23 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
24 |
/** |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
25 |
* @test |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
26 |
* @bug 7147084 |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
27 |
* @run main/othervm InheritIOEHandle |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
28 |
* @summary inherit IOE handles and MS CreateProcess limitations (kb315939) |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
29 |
*/ |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
30 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
31 |
import java.io.BufferedReader; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
32 |
import java.io.File; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
33 |
import java.io.IOException; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
34 |
import java.io.InputStreamReader; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
35 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
36 |
public class InheritIOEHandle { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
37 |
private static enum APP { |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
38 |
A, B, C; |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
39 |
} |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
40 |
|
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
41 |
private static File stopC = new File("StopC.txt"); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
42 |
private static String SIGNAL = "After call child process"; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
43 |
private static String JAVA_EXE = System.getProperty("java.home") |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
44 |
+ File.separator + "bin" |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
45 |
+ File.separator + "java"; |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
46 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
47 |
private static String[] getCommandArray(String processName) { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
48 |
String[] cmdArray = { |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
49 |
JAVA_EXE, |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
50 |
"-cp", |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
51 |
System.getProperty("java.class.path"), |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
52 |
InheritIOEHandle.class.getName(), |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
53 |
processName |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
54 |
}; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
55 |
return cmdArray; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
56 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
57 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
58 |
public static void main(String[] args) throws Exception { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
59 |
if (!System.getProperty("os.name").startsWith("Windows")) { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
60 |
return; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
61 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
62 |
|
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
63 |
APP app = (args.length > 0) ? APP.valueOf(args[0]) : APP.A; |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
64 |
switch (app) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
65 |
case A: |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
66 |
performA(); |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
67 |
break; |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
68 |
case B: |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
69 |
performB(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
70 |
break; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
71 |
case C: |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
72 |
performC(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
73 |
break; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
74 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
75 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
76 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
77 |
private static void performA() { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
78 |
try { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
79 |
stopC.delete(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
80 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
81 |
ProcessBuilder builder = new ProcessBuilder( |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
82 |
getCommandArray(APP.B.name())); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
83 |
builder.redirectErrorStream(true); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
84 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
85 |
Process process = builder.start(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
86 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
87 |
process.getOutputStream().close(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
88 |
process.getErrorStream().close(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
89 |
|
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
90 |
boolean isSignalReceived = false; |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
91 |
try (BufferedReader in = new BufferedReader(new InputStreamReader( |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
92 |
process.getInputStream(), "utf-8"))) |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
93 |
{ |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
94 |
String result; |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
95 |
while ((result = in.readLine()) != null) { |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
96 |
if (SIGNAL.equals(result)) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
97 |
isSignalReceived = true; |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
98 |
break; |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
99 |
} else { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
100 |
throw new RuntimeException("Catastrophe in process B! Bad output."); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
101 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
102 |
} |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
103 |
|
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
104 |
} |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
105 |
if (!isSignalReceived) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
106 |
throw new RuntimeException("Signal from B was not received"); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
107 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
108 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
109 |
// If JDK-7147084 is not fixed that point is unreachable. |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
110 |
System.out.println("Received signal from B, creating file StopC"); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
111 |
// write signal file |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
112 |
boolean isFileStopC = stopC.createNewFile(); |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
113 |
if (!isFileStopC) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
114 |
throw new RuntimeException("Signal file StopC.txt was not created. TEST or INFRA bug"); |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
115 |
} |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
116 |
|
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
117 |
process.waitFor(); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
118 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
119 |
System.err.println("Read stream finished."); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
120 |
} catch (IOException ex) { |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
121 |
throw new RuntimeException("Catastrophe in process A!", ex); |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
122 |
} catch (InterruptedException ex) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
123 |
throw new RuntimeException("A was interrupted while waiting for B", ex); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
124 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
125 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
126 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
127 |
private static void performB() { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
128 |
try { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
129 |
ProcessBuilder builder = new ProcessBuilder( |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
130 |
getCommandArray(APP.C.name())); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
131 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
132 |
Process process = builder.start(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
133 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
134 |
process.getInputStream().close(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
135 |
process.getOutputStream().close(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
136 |
process.getErrorStream().close(); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
137 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
138 |
System.out.println(SIGNAL); |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
139 |
process.waitFor(); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
140 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
141 |
// JDK-7147084 subject: |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
142 |
// Process C inherits the [System.out] handle and |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
143 |
// handle close in B does not finalize the streaming for A. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
144 |
// (handle reference count > 1). |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
145 |
} catch (IOException ex) { |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
146 |
throw new RuntimeException("Catastrophe in process B!", ex); |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
147 |
} catch (InterruptedException ex) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
148 |
throw new RuntimeException("B was interrupted while waiting for C", ex); |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
149 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
150 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
151 |
|
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
152 |
private static void performC() { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
153 |
// If JDK-7147084 is not fixed the loop is 5min long. |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
154 |
for (int i = 0; i < 5 * 60; ++i) { |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
155 |
try { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
156 |
Thread.sleep(1000); |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
157 |
} catch (InterruptedException ex) { |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
158 |
// that is ok. Longer sleep - better effect. |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
159 |
} |
21294
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
160 |
// check for success |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
161 |
if (stopC.exists()) { |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
162 |
break; |
545dfa5b947e
8024660: TEST_BUG: java/lang/ProcessBuilder/*IOHandle.java leaving hotspot.log open in fastdebug builds
robm
parents:
19372
diff
changeset
|
163 |
} |
19372
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
164 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
165 |
} |
e404c834f1cd
7147084: (process) appA hangs when read output stream of appB which starts appC that runs forever
uta
parents:
diff
changeset
|
166 |
} |