我已经开始执行以下代码
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "path"); try { Process p = pb.start(); } catch (IOException ex) {}
现在,我需要知道我刚刚开始的进程的pid。
由于Java 9类Process具有新方法long pid(),因此它很简单
Process
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "path"); try { Process p = pb.start(); long pid = p.pid(); } catch (IOException ex) { // ... }