Process Object from Apache Commons Exec

淺唱寂寞╮ 提交于 2019-12-11 07:01:29

问题


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:


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.



来源:https://stackoverflow.com/questions/7625758/process-object-from-apache-commons-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!