28 import static java.util.Arrays.stream;
29 import static java.util.stream.Collectors.joining;
30 import static java.util.stream.Collectors.toList;
31 import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder;
32 import static jdk.test.lib.Platform.isWindows;
33
34 import java.io.BufferedReader;
35 import java.io.File;
36 import java.io.FileNotFoundException;
37 import java.io.FileOutputStream;
38 import java.io.IOException;
39 import java.io.InputStreamReader;
40 import java.util.Collection;
41 import java.util.Optional;
42 import java.util.stream.Stream;
43
44 /*
45 * @test TestInheritFD
46 * @bug 8176717 8176809
47 * @summary a new process should not inherit open file descriptors
48 * @library /test/lib
49 * @modules java.base/jdk.internal.misc
50 * java.management
51 */
52
53 /**
54 * Test that HotSpot does not leak logging file descriptors.
55 *
56 * This test is performed in three steps. The first VM starts a second VM with
57 * gc logging enabled. The second VM starts a third VM and redirects the third
58 * VMs output to the first VM, it then exits and hopefully closes its log file.
59 *
60 * The third VM waits for the second to exit and close its log file. After that,
61 * the third VM tries to rename the log file of the second VM. If it succeeds in
62 * doing so it means that the third VM did not inherit the open log file
63 * (windows can not rename opened files easily)
64 *
65 * The third VM communicates the success to rename the file by printing "CLOSED
66 * FD". The first VM checks that the string was printed by the third VM.
67 *
|
28 import static java.util.Arrays.stream;
29 import static java.util.stream.Collectors.joining;
30 import static java.util.stream.Collectors.toList;
31 import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder;
32 import static jdk.test.lib.Platform.isWindows;
33
34 import java.io.BufferedReader;
35 import java.io.File;
36 import java.io.FileNotFoundException;
37 import java.io.FileOutputStream;
38 import java.io.IOException;
39 import java.io.InputStreamReader;
40 import java.util.Collection;
41 import java.util.Optional;
42 import java.util.stream.Stream;
43
44 /*
45 * @test TestInheritFD
46 * @bug 8176717 8176809
47 * @summary a new process should not inherit open file descriptors
48 * @comment On Aix lsof requires root privileges.
49 * @requires os.family != "aix"
50 * @library /test/lib
51 * @modules java.base/jdk.internal.misc
52 * java.management
53 */
54
55 /**
56 * Test that HotSpot does not leak logging file descriptors.
57 *
58 * This test is performed in three steps. The first VM starts a second VM with
59 * gc logging enabled. The second VM starts a third VM and redirects the third
60 * VMs output to the first VM, it then exits and hopefully closes its log file.
61 *
62 * The third VM waits for the second to exit and close its log file. After that,
63 * the third VM tries to rename the log file of the second VM. If it succeeds in
64 * doing so it means that the third VM did not inherit the open log file
65 * (windows can not rename opened files easily)
66 *
67 * The third VM communicates the success to rename the file by printing "CLOSED
68 * FD". The first VM checks that the string was printed by the third VM.
69 *
|