My program is using exec.Command
to run a child process (that I don't control), which is in turn kicking off another child process. The problem is that the second child process is not running under the first child process, but instead the original process, leaving me no way to explicitly kill it if I need to. And I do need to.
So, is there a platform-agnostic way to list subprocesses, so that I can explicitly clean it up?
The platform agnostic way would be to use PID files, or some other similar mechanism. The downside is that you have to get the subprocess applications (and their vendors) to produce the necessary information.
The only other possibility is developing your own multi-platform library, as the subprocess semantics and the process related APIs change from platform to platform. The a few utilities that exist simply get a list of all processes in the system, and query for each one's parent pid, and build a tree using custom logic.