in reply to Managing Process Handles

  1. The handle will be closed at block exit if the handle is lexical, at script end otherwise.
  2. Yes.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Managing Process Handles
by graff (Chancellor) on Oct 19, 2002 at 07:34 UTC
    Hmm. Okay, maybe I was being a bit rash when I said the short answer to "2." was "no" -- what I should have said was "yes, sort of, but you don't really get your desired result". At least, as I understand the OP, it would not be desirable to write a statement to the pipe handle after the downstream process has ended.

    And based on my experiments (simple-minded, but functional, I think), there's no way around losing at least one print statement after the pipe process exits (because the previous statement caused that process to terminate on its own initiative).

    Another thought -- not pretty, but... -- opening a pipe returns a pid, right? and maybe there's something that one could do within a loop, before printing to the pipe handle, to see if that pid is still running.

      there's no way around losing at least one print statement after the pipe process exits

      So interleave innocuous commands between the other messages.

      My suggestion is based on the assumption that a brittle kluge is all that is needed.