Get subprocess id in Java

前端 未结 5 909
悲&欢浪女
悲&欢浪女 2020-12-06 05:55

I\'m creating subprocesses in this way:

String command = new String(\"some_program\");

Process p = Runtime.getRuntime().exec(command);

How

5条回答
  •  臣服心动
    2020-12-06 06:07

    Trivial on linux:

    String pid = new File("/proc/self").getCanonicalFile().getName();
    

提交回复
热议问题