in reply to Re^2: Using Linux Commands in Perl - `Backticks`
in thread Using Linux Commands in Perl - `Backticks`

Duh - I misread that. In that case, using select and alarm is likely the best approach.

Luckily, the question is about Linux, where this approach will work. On Windows, reading from a pipe does not play well with select and/or IO::Select. The approaches of tunnelling the IO through (TCP) sockets (in the Win32 mkpipe emulation) do work for certain cases and horribly fail for other cases, always depending on the program spawned in such a fashion.

  • Comment on Re^3: Using Linux Commands in Perl - `Backticks`

Replies are listed 'Best First'.
Re^4: Using Linux Commands in Perl - `Backticks`
by JavaFan (Canon) on Oct 01, 2010 at 08:54 UTC
    Considering that select() already has a timeout, why would you use alarm?

      I've never used select with a timeout, so that's why I wasn't aware of that additional parameter. As you say, there is no reason to use alarm, as select does everything that's needed to read from a program for a limited amount of time.

        I've never used select with a timeout,
        I guess you mean that you've never used select (the select that's a wrapper around the select(2) system call) ;-)? You cannot use 2 or 3 arguments for select - if you use select to know the status of filehandles, you must give it a timeout. It won't compile otherwise.