3

I am invoking a command which spawns two processes

Process p = Runtime.getRuntime().exec("<...>\bin\\script");

" process 1 with the pid 1234, process 2 with the ppid 1234, pid 3456 "

I can get the process id(1234) by the following code :

String name = ManagementFactory.getRuntimeMXBean().getName();
String processId = name.split("@")[0];
System.out.println("Process ID for this app =  " + processId);

But I cant get the other process's id (3456). Is there a way to extract all the child process ids from a process?

nandini
  • 428
  • 2
  • 9
  • 20
  • You might want to find it from the `Process` object. See e.g. http://stackoverflow.com/questions/4750470/how-to-get-pid-of-process-ive-just-started-within-java-program – dejvuth Jan 14 '16 at 09:28
  • Could [this](http://stackoverflow.com/a/10124625/5128464) help you (windows specific solution)? – vlp Jan 14 '16 at 10:08
  • @vlp I have gone through the link you provided.. but need it platform independent. Thanks. – nandini Jan 14 '16 at 11:44

0 Answers0