in reply to Re (tilly) 3: need help with open2, please!
in thread need help with open2, please!

call select on those file handles to prevent the reader/writer dead-locking. (Or just fork into seperate reader/writer process if that's feasible).
  • Comment on Re: Re (tilly) 3: need help with open2, please!

Replies are listed 'Best First'.
Re (tilly) 5: need help with open2, please!
by tilly (Archbishop) on May 06, 2001 at 15:38 UTC
    I thought about suggesting select to turn off buffering, but didn't recommend that directly because it is less reliable.

    What select would do is affect how you are buffering your communication to the other process. But you cannot with select guarantee that it won't buffer the input coming from you, in which case you are still SOL. But when you close the handle, your contents get flushed and it will know from the eof that there is no more to buffer.

    Incidentally this is the basic danger with open2 and open3. You have to be very careful that your assumptions and the assumptions of the other program do not conflict in any way. For instance the above pattern (send, close, then read the response) works fine for small amounts of data. But if you try to send more than a page or 2 at once, it may decide to send you a response to the first bit before getting more from you. But you are still trying to send information. When this happens to you at a party, it is only mildly annoying. Humans being multi-tasking, one or the other usually spots the problem and the issue is resolved. But programs are willing to block on communication over this kind of boneheaded mistake for as long as it takes...