4 ms·
Won't it just get buffered into the other program's input buffer? I believe pipes are block-buffered and basically look just like redirecting to a file.
by Periodic 17y ago
Won't it just get buffered into the other program's input buffer?
I believe pipes are block-buffered and basically look just like redirecting to a file.
- jrockway 17y agoIf the process you're piping to never reads stdin and your process writes to stdout with a blocking write, you will eventually be blocked. But just use an event loop for stdout, and all will be well. (That way your program is in control of its own buffering and blocking. select is probably good enough in this case.) Anyway, if you want to see freakin' echo block because of this, try: $ mkfifo foo $ echo "OH HAI" > foo <blocks> In another xterm: $ cat foo <echo unblocks and exits>.
- btilly 17y agoThe potential problem comes when stdout and stderr are going to different places. For instance stdout is going to the next stage in a pipeline while stderr is going to the console. Then the error message winds up waiting for the buffering program.
- gte910h 17y agoYes exactly. This is the scenario I'm worried about. It's pretty common actually (think logging, etc)