Ticket #12636 (closed defect: fixed)
Blocking pipe write in Unix?
| Reported by: | ryazanov | Owned by: | vadz |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | base | Version: | 2.9-svn |
| Keywords: | Cc: | ||
| Blocked By: | Patch: | no | |
| Blocking: |
Description
It seems, that wxProcess/wxExecute in Unix do not make the output pipe (connected to process' stdin) non-blocking. So, contrary to wxOutputStream::Write documentation (In some cases (for example a write end of a pipe which is currently full) it is even possible that there is no errors and zero bytes have been written.), an attempt to write to a full pipe can create a deadlock -- child process cannot read from the input pipe, if its output pipe is full, and that pipe can't be read out, because the main program waits in the Write().
Supporting evidence:
- I didn't find any kind of O_NONBLOCK in the relevant source files.
- The deadlock occurs for bzip2, which operates on large blocks of data, and does not occur for gzip, which uses smaller blocks.
- Addition of delays (wxMilliSleep(100)) after each Write() removes the deadlock, presumably giving bzip2 enough time to process the data and start output before the input pipe fills up.
P.S. The problem does not appear in wxMSW (and there is PIPE_NOWAIT in msw/utilsexc.cpp).

