Skip to content
  • Michael Pyne's avatar
    util: Check that an executable exists before pipe-reading from it. · 3337c9e6
    Michael Pyne authored
    Perl's "open '-|' $program" feature, which is used to pipe the output of
    a process to a filehandle variable, is implemented internally using
    pipes along with a fork/exec construct. The pipes are created, your
    process automatically forks, and the child exec(2)'s the command you
    wished to run.
    
    This is all documented, and I thought I had a handle on this, but Perl's
    open() function's error checking is based only on whether fork(2)
    succeeded, not on whether exec(2) succeeded.
    
    What I think we get when we don't check for errors is some kind of
    raised signal (e.g. SIGPIPE) which is then duly received by the existing
    async-IPC code (which is already doing multi-proc), which then kills the
    IPC procs due to the 'impossible SIGPIPE' happening and crashes
    kdesrc-build.
    
    This fix, to check for an executable before trying to run, should at
    least make this kind of error more apparent (this isn't perfect yet
    either since 'bzr' failing to exist during pretend mode should be listed
    as an update failure, not update success). I would still need to find a
    better way to handle this since this is still a race condition.
    
    CCBUG:345425
    3337c9e6