|
1 | 1 | /* |
2 | | - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2003, 2026, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -66,26 +66,19 @@ public boolean timedOut() { |
66 | 66 | * @param pids the processes to dump status for |
67 | 67 | */ |
68 | 68 | static void dumpState(Process... pids) { |
69 | | - if (!System.getProperty("os.name").contains("SunOS")) { |
70 | | - return; |
71 | | - } |
72 | 69 | try { |
73 | 70 | String[] psArgs = {"ps", "-elf"}; |
74 | | - Process ps = new ProcessBuilder(psArgs).inheritIO().start(); |
75 | | - ps.waitFor(); |
76 | | - String[] sfiles = {"pfiles", "self"}; |
77 | | - Process fds = new ProcessBuilder(sfiles).inheritIO().start(); |
78 | | - fds.waitFor(); |
| 71 | + try (Process ps = new ProcessBuilder(psArgs).inheritIO().start()) { |
| 72 | + ps.waitFor(); |
| 73 | + } |
79 | 74 |
|
80 | 75 | for (Process p : pids) { |
81 | 76 | if (p == null) |
82 | 77 | continue; |
83 | | - String[] pfiles = {"pfiles", Long.toString(p.pid())}; |
84 | | - fds = new ProcessBuilder(pfiles).inheritIO().start(); |
85 | | - fds.waitFor(); |
86 | | - String[] pstack = {"pstack", Long.toString(p.pid())}; |
87 | | - fds = new ProcessBuilder(pstack).inheritIO().start(); |
88 | | - fds.waitFor(); |
| 78 | + String[] pfiles = {"lsof", "-p", Long.toString(p.pid())}; |
| 79 | + try (Process fds = new ProcessBuilder(pfiles).inheritIO().start()) { |
| 80 | + fds.waitFor(); |
| 81 | + } |
89 | 82 | } |
90 | 83 | } catch (IOException | InterruptedException i) { |
91 | 84 | i.printStackTrace(); |
|
0 commit comments