[rfc][icedtea-web] replace runtime().exec by processbuilder

Andrew Azores aazores at redhat.com
Mon Jun 15 16:37:32 UTC 2015


On 15/06/15 12:26 PM, Jiri Vanek wrote:
>
>> I don't know about "keep going" and what that would actually mean in 
>> this case and what kind of
>> behaviour would arise. "Die" sounds reasonable, though, but then we 
>> need to check if p is actually
>> finished after we wake up and then decide to die if it isn't - so 
>> then why not instead of dying just
>> waitFor p again?
>
>
> May you provide code snippet please?

             ProcessBuilder pb = new ProcessBuilder(command);
             pb.inheritIO();
             Process p = pb.start();
             boolean pTerminated = false;
             while (!pTerminated) {
                 try {
                     p.waitFor();
                 } catch (InterruptedException e) {
OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
                 }
                 try {
                     p.exitValue();
                     pTerminated = true;
                 } catch (IllegalThreadStateException e) {
OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
                 }
             }

Hopefully the formatting survives.

>
> Is this kind of awaking really worthy of surviving?  I'm really 
> inclined to just catch, log, and continue ITW running...
>
> J.

It's not that hard to correctly handle it, although the code does look 
pretty ugly. I think the better question to ask is if a spurious wakeup 
does occur here, will ITW continue to run properly? Because like I said, 
it's possible that the wakeup occurs and there is no exception to catch 
or log, and so you just end up with a silent failure later on.

-- 
Thanks,

Andrew Azores



More information about the distro-pkg-dev mailing list