Process Object from Apache Commons Exec

2019-08-03 23:46发布

I'm using the Apache Commons Exec jars for creating processes. However I'd like to get control of the process id of processes being invoked.

Is there a way of getting the 'Process' object from the Apache Commons Exec api? I did'nt fine any public methods that returns the 'Process class.

1条回答
劳资没心,怎么记你
2楼-- · 2019-08-04 00:00

See http://commons.apache.org/exec/apidocs/index.html

Interface CommandLauncher contains several exec methods that return Process.

But anyway you do not have any way to control the process ID: it is the OS responsibility. Moreover standard java API does not allow you even to retrieve the process ID. There was a trick in older java versions: the implementation of Process contained int field pid that could be retrieved using reflection. But this was changed in version 1.6.

查看更多
登录 后发表回答