Re: Obtain process ID of DefaultExecutor process
Gary Gregory <[email protected]> Wed, 25 Feb 2026 15:53:06 -0500
| Newsgroups | gmane.comp.jakarta.commons.user |
|---|---|
| Message-ID | <CACZkXPx980c_w1mhvEp9xVn9yinAbGk8_wLTwARWH_9d+fQZYQ@mail.gmail.com> |
On Sat, Feb 21, 2026 at 9:12=E2=80=AFAM Tenenbaum, Peter G. (ARC-TN)[SETI INSTITUTE] via user <[email protected]> wrote: > > Hi there =E2=80=94 > > I was looking for a way to get the process ID of a process that gets star= ted by the DefaultExecutor. From looking at the javadoc, there=E2=80=99s no= built-in way to do it. > > Google recommends that I create a subclass of DefaultExecutor that overri= des the launch() method, such that the Process it returns is interrogated f= or the PID. DefaultExecutor isn=E2=80=99t final and launch() is protected, = so in principle this can be done. > > However: > > The only public constructor for DefaultExecutor is deprecated. The non-de= precated method to instantiate a DefaultExecutor is to use the DefaultExecu= tor builder, but AFAICT there=E2=80=99s no way to get this builder to retur= n a DefaultExecutor subclass. I could subclass the DefaultExecutor builder,= but the DefaultExecutor builder uses a package-private DefaultExecutor con= structor, so my subclass of DefaultExecutor builder can=E2=80=99t use that = constructor. > > In a pinch, I could imagine giving my subclass its own constructor that e= mulates the package-private one in DefaultExecutor. Unfortunately, this als= o won=E2=80=99t work: all the instance variables are private and there are = no protected setters for them. > > It seems like the intent is there to allow users to subclass DefaultExecu= tor, but in practice the only way to do it appears to be the deprecated pub= lic constructor. Am I missing something? > > Is there an easier way to get the PID from a DefaultExecutor? Hello PT, Have you tried registering an ExecuteWatchdog with a DefaultExecutor? It accepts a Process that you can query. Gary > > Thanks, > -PT