[rfc][icedtea-web] replace runtime().exec by processbuilder
Jiri Vanek
jvanek at redhat.com
Mon Jun 15 15:57:59 UTC 2015
On 06/15/2015 05:46 PM, Andrew Azores wrote:
> On 15/06/15 11:34 AM, Jiri Vanek wrote:
>> ssia
>>
>>
>> I'm also in temptation to push this to 1.6
>>
>> The handling of streams is just terrible :(
>>
>>
>> J.
>
>> - Process p = Runtime.getRuntime().exec(command);
>> - new StreamEater(p.getErrorStream()).start();
>> - new StreamEater(p.getInputStream()).start();
>> - p.getOutputStream().close();
>> -
>> + ProcessBuilder pb = new ProcessBuilder(command);
>> + pb.inheritIO();
>> + Process p =pb.start();
>> + try {
>> + p.waitFor();
>> + } catch (InterruptedException e) {
>> + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
>> + }
>
> Where does the "waitFor" come from? I'm not seeing that the old code does the same thing (but maybe
Surprisingly no - the change of behavior is to not include it.
The wait is hidden in the handling of streams.
As streaminheritance is different, then the waitFor is the necessarything to do.
> I'm just missing it and it does). Is this meant to be a change in behaviour? If that
> InterruptedException does get thrown, is it ok that the current thread continues on in parallel with
> process p?
For that I dont have answer. Whats your suggestion? HAve you ever seenthis exception? :)
J
More information about the distro-pkg-dev
mailing list