Another ProcessBuilder enhancement: execve

David M. Lloyd david.lloyd at
Fri Oct 21 18:58:15 UTC 2016

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. 

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.


More information about the core-libs-dev mailing list