How to know start and kill processes within Java code (or C or Python) on *nix

Posted by recipriversexclusion on Stack Overflow See other posts from Stack Overflow or by recipriversexclusion
Published on 2010-04-15T18:50:14Z Indexed on 2010/04/15 18:53 UTC
Read the original article Hit count: 241

Filed under:
|
|

I need to write a process controller module on Linux that handles tasks, which are each made up of multiple executables. The input to the controller is an XML file that contains the path to each executable and list of command line parameters to be passed to each. I need to implement the following functionality:

  1. Start each executable as an independent
  2. Be able to kill any of the created processes independent of the others

In order to do (2), I think I need to capture the pid when I create a process, to issue a system kill command. I tried to get access to pid in Java but saw no easy way to do it.

All my other logic (putting info about the tasks in DB, etc) is done in Java so I'd like to stick with that, but if there are solutions you can suggest in C, C++, or Python I'd appreciate those, too.

© Stack Overflow or respective owner

Related posts about processes

Related posts about java