We need to make at least one end of the pipe used to communicate with
wxExecute() child process non-blocking to avoid deadlocks, so unblock the
write end of the pipe. It seems to be unnecessary to unblock the reading ends
of std{out,err} pipes as we can already check for the presence of input there.
This is also consistent with wxMSW behaviour.
Closes #12636.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65993
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
if ( process && process->IsRedirected() )
{
if ( process && process->IsRedirected() )
{
+ // Avoid deadlocks which could result from trying to write to the
+ // child input pipe end while the child itself is writing to its
+ // output end and waiting for us to read from it.
+ if ( !pipeIn.MakeNonBlocking(wxPipe::Write) )
+ {
+ // This message is not terrible useful for the user but what
+ // else can we do? Also, should we fail here or take the risk
+ // to continue and deadlock? Currently we choose the latter but
+ // it might not be the best idea.
+ wxLogSysError(_("Failed to set up non-blocking pipe, "
+ "the program might hang."));
+ }
+
wxOutputStream *inStream =
new wxFileOutputStream(pipeIn.Detach(wxPipe::Write));
wxOutputStream *inStream =
new wxFileOutputStream(pipeIn.Detach(wxPipe::Write));