Blocking pipe write in Unix?
|Reported by:||ryazanov||Owned by:||vadz|
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().
- 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).
Change History (22)
comment:1 Changed 4 years ago by vadz
- Component changed from wxGTK to base
- Owner set to vadz
- Status changed from new to accepted
- Version changed from 2.8.11 to 2.9-svn
comment:5 follow-up: ↓ 6 Changed 4 years ago by vadz
- Resolution fixed deleted
- Status changed from closed to reopened