blob: 61fd5b7409f9049a731bbe124f894c9baf93b301 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Create a long running process and verify that the exitValue is not
// immediately available. Then destroy() it and verify that it
// terminates quickly with a non-zero exitValue.
public class Process_5
{
public static void main(String[] args)
{
try
{
int c;
long startTime = System.currentTimeMillis();
Runtime r = Runtime.getRuntime();
String[] a = { "sleep", "120" };
Process p = r.exec(a);
try
{
c = p.exitValue();
System.out.println("bad 1");
return;
}
catch (IllegalThreadStateException itse)
{
// Ignore as this is good here.
}
p.destroy();
c = p.waitFor();
long endTime = System.currentTimeMillis();
if (endTime - startTime > 110000L)
System.out.println("bad 2");
System.out.println(c != 0 ? "ok" : "bad 3");
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
}
|