I’ve been trying to communicate with a perl process from PLT Scheme using the process library call from scheme/system.
I’ve been a good systems boy making sure that I call flush-output after every string I write to the perl process. But the perl process never gets any input unless I close the output side of the pipe connected to perl’s stdin filehandle.
After hours of no progress I found this
http://pre.plt-scheme.org/plt/doc/release-notes/mzscheme/MzScheme_300.txt
* File-stream output ports (including file ports, the initial output
port, and ports created by `subprocess’) are now block-buffered by
default, instead of line-buffered. The exception is when an output
port corresponds to a terminal, in which case it is line-buffered
by default. Also, the initial error port remains unbuffered.TCP output ports are block buffered (instead of unbuffered) by
default.The file-stream changes are especially likely to affect stdio-based
communication among OS-level processes. For example, when
communicating with an ispell subprocess, adding a newline at the
end of a command previously would have been enough to send the
command to ispell. Now, the output must be flushed explicitly
(using `flush-output’) or the buffer mode must be explicitly
changed to by-line (using `file-stream-buffer-mode’).The TCP changes affect most TCP-based communication. Explicitly
flush output using `flush-output’ or change the buffer mode using
`file-stream-buffer-mode’.
So I said what the heck, I’ll just add a (file-stream-buffer-mode outp ‘line)
call for grins.
And it started working.



