2

I start a Process with ProcessBuilder but i need to get the PID. (Process ID)

List<String> bel = Arrays.asList(befehl.split(","));
ProcessBuilder bu2 = new ProcessBuilder(bel);
bu2.directory(new File("/home/cloud/" + modi + "/" + name));
Process p = bu2.start();

How can i dot that?

rudolfovic
  • 3,163
  • 2
  • 14
  • 38
PieHora
  • 31
  • 1
  • 2

1 Answers1

1
ProcessHandle processHandle = p.toHandle();
System.out.printf("PID: %s%n", processHandle.pid());
doku
  • 73
  • 9