author | simonis |
Tue, 26 Nov 2013 16:40:31 +0100 | |
changeset 22597 | 7515a991bb37 |
parent 12538 | 211d6e82fe51 |
child 27785 | 29d4cb4a8f5e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
12538
211d6e82fe51
7130404: [macosx] "os.arch" value should be "x86_64" for compatibility with Apple JDK6
jmelvin
parents:
12047
diff
changeset
|
2 |
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 6474073 |
|
27 |
* @summary Make sure zombies don't get created on Unix |
|
28 |
* @author Martin Buchholz |
|
29 |
*/ |
|
30 |
||
31 |
import java.io.*; |
|
32 |
||
33 |
public class Zombies { |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
34 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
35 |
static final String os = System.getProperty("os.name"); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
36 |
|
12538
211d6e82fe51
7130404: [macosx] "os.arch" value should be "x86_64" for compatibility with Apple JDK6
jmelvin
parents:
12047
diff
changeset
|
37 |
static final String TrueCommand = os.contains("OS X")? |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
38 |
"/usr/bin/true" : "/bin/true"; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
39 |
|
2 | 40 |
public static void main(String[] args) throws Throwable { |
41 |
if (! new File("/usr/bin/perl").canExecute() || |
|
42 |
! new File("/bin/ps").canExecute()) |
|
43 |
return; |
|
44 |
System.out.println("Looks like a Unix system."); |
|
45 |
final Runtime rt = Runtime.getRuntime(); |
|
46 |
||
47 |
try { |
|
48 |
rt.exec("no-such-file"); |
|
49 |
throw new Error("expected IOException not thrown"); |
|
50 |
} catch (IOException _) {/* OK */} |
|
51 |
||
52 |
try { |
|
53 |
rt.exec("."); |
|
54 |
throw new Error("expected IOException not thrown"); |
|
55 |
} catch (IOException _) {/* OK */} |
|
56 |
||
57 |
try { |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
58 |
rt.exec(TrueCommand, null, new File("no-such-dir")); |
2 | 59 |
throw new Error("expected IOException not thrown"); |
60 |
} catch (IOException _) {/* OK */} |
|
61 |
||
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
62 |
rt.exec(TrueCommand).waitFor(); |
2 | 63 |
|
64 |
// Count all the zombies that are children of this Java process |
|
65 |
final String[] zombieCounter = { |
|
66 |
"/usr/bin/perl", "-e", |
|
67 |
"exit @{[`/bin/ps -eo ppid,s` =~ /^ *@{[getppid]} +Z$/mog]}" |
|
68 |
}; |
|
69 |
||
70 |
int zombies = rt.exec(zombieCounter).waitFor(); |
|
71 |
if (zombies != 0) throw new Error(zombies + " zombies!"); |
|
72 |
} |
|
73 |
} |