来自Apache Commons Exec的过程对象 [英] Process Object from Apache Commons Exec
问题描述
我正在使用Apache Commons Exec jar创建进程.但是,我想控制正在调用的进程的进程ID.
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.
是否可以从Apache Commons Exec api获取"Process"对象?我没有对返回"Process类"的任何公共方法进行罚款.
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.
推荐答案
请参见 http://commons.apache.org/exec/apidocs/index.html
Interface CommandLauncher包含几个返回Process
的exec
方法.
Interface CommandLauncher contains several exec
methods that return Process
.
但是无论如何,您没有任何方法可以控制进程ID:这是操作系统的责任.此外,标准的Java API甚至不允许您检索进程ID.在较早的Java版本中有一个技巧:Process的实现包含int字段pid,可以使用反射来检索它.但这在1.6版中已更改.
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.
这篇关于来自Apache Commons Exec的过程对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!