Another ProcessBuilder enhancement: execve

Martin Buchholz martinrb at
Fri Oct 21 19:07:14 UTC 2016

Historically, this was thought to be not an option because Windows doesn't
have exec (or fork).
Cygwin's emulation of fork does create a windows subprocess, I believe.

The desire to have clean shutdown of the Java process does make things more
interesting as well, as you point out.

One use case is discovering you would like different JVM flags while you
are running.

On Fri, Oct 21, 2016 at 11:58 AM, David M. Lloyd <david.lloyd at>

> It would be useful for processes which self-update or otherwise
> self-manage to be able to exec a new process which replaces the current
> one, in the manner of POSIX execve.  This might tie in with ProcessBuilder,
> though there are a few key differences:
> 1. The method to execute the process (obviously) would never normally
> return, similarly to how System.exit() doesn't normally return.
> 2. The options for redirection would be necessarily limited to File,
> INHERIT, or DISCARD; PIPE does not make sense since the current process
> would be eliminated.
> Another interesting characteristic is that this would be essentially a
> hybrid between System.exit() and ProcessBuilder.start(), from both an
> execution perspective (as mentioned above) and a security perspective, in
> that the caller would have to be authorized both to terminate the VM (i.e.
> SecurityManager.checkExit(0), or potentially a new check specific to this
> operation) and also to exec the target process (i.e.
> SecurityManager.checkExec(fileName)).
> Exiting or exec'ing another process during JVM shutdown-for-exec should be
> disallowed, though the former could be tolerated in the same way that
> calling exit() during an in-progress shutdown is tolerated today (i.e.
> indefinite blocking).
> My understanding is that Windows has at least one way to accomplish the
> same effect as well, but that bears more research than my quick web search.
> I know the time is past for 9, but I think this idea might be good to
> explore for 10, or at least make for an interesting discussion.
> Thoughts?
> --
> - DML

More information about the core-libs-dev mailing list