On Wed, 5 Jun 2002, Steve Thomas wrote: > Anyone know how to open a file/command (open FOO, "|foo"), write to it > and then read back from it?
The trouble with this is that both the "opener" process and the "opened" process have to be prepared for interprocess communication. If either of them attempts to read more than the other process has written, or to write more than [the OS I/O buffer size + however much the other process is prepared to read] through the connection, that process will block and potentially deadlock the entire conversation. It's not sufficient to make just one of the two "well-behaved." So you can't do this in the general case with any old command. You're much better off opening the pipe only for writing and sending the output of the command to a file, then reading back in the file contents after the command has finished; or, alternately, dump the input to the command into a file and open the pipe for reading. However, bidirectional piping *might* work for SA, because SA has to consume the entire message as input before it can generate usefule output, so you avoid the problem with "simultaneous" reads and writes. If that's the case, have a look at IO::Pipe. Just keep in mind that spamc won't read more than 250kb, so either you need to preflight the messages and avoid trying to filter large ones, or do non-blocking writes and be prepared to give up (and not expect any output back) after 250k has been transmitted. I believe spamass-milter had (has?) a deadlocking problem because it failed to do this. _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk