+#if wxUSE_GUI
+
+#ifdef __DARWIN__
+ #include <sys/errno.h>
+#endif
+// ----------------------------------------------------------------------------
+// wxExecute support
+// ----------------------------------------------------------------------------
+
+/*
+ NOTE: If this proves not to work well for wxMac then move back to the old
+ behavior. If, however, it proves to work just fine, nuke all of the code
+ for the old behavior. I strongly suggest backporting this to 2.8 as well.
+ However, beware that while you can nuke the old code here, you cannot
+ nuke the wxAddProcessCallbackForPid from the 2.8 branch (found in
+ utilsexc_cf since it's an exported symbol).
+ */
+// #define USE_OLD_DARWIN_END_PROCESS_DETECT (defined(__DARWIN__) && defined(__WXMAC__))
+#define USE_OLD_DARWIN_END_PROCESS_DETECT 0
+
+// wxMac/wxCocoa don't use the same process end detection mechanisms so we don't
+// need wxExecute-related helpers for them
+#if !USE_OLD_DARWIN_END_PROCESS_DETECT
+
+bool wxGUIAppTraits::CreateEndProcessPipe(wxExecuteData& execData)
+{
+ return execData.pipeEndProcDetect.Create();
+}
+
+bool wxGUIAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& execData, int fd)
+{
+ return fd == (execData.pipeEndProcDetect)[wxPipe::Write];
+}
+
+void wxGUIAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& execData)
+{
+ execData.pipeEndProcDetect.Detach(wxPipe::Write);
+ execData.pipeEndProcDetect.Close();
+}
+
+#else // !Darwin
+
+bool wxGUIAppTraits::CreateEndProcessPipe(wxExecuteData& WXUNUSED(execData))
+{
+ return true;
+}
+
+bool
+wxGUIAppTraits::IsWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(execData),
+ int WXUNUSED(fd))
+{
+ return false;
+}
+
+void
+wxGUIAppTraits::DetachWriteFDOfEndProcessPipe(wxExecuteData& WXUNUSED(execData))
+{
+ // nothing to do here, we don't use the pipe
+}
+
+#endif // !Darwin/Darwin
+
+int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
+{
+ wxEndProcessData *endProcData = new wxEndProcessData;
+
+ const int flags = execData.flags;
+
+ // wxAddProcessCallback is now (with DARWIN) allowed to call the
+ // callback function directly if the process terminates before
+ // the callback can be added to the run loop. Set up the endProcData.
+ if ( flags & wxEXEC_SYNC )
+ {
+ // we may have process for capturing the program output, but it's
+ // not used in wxEndProcessData in the case of sync execution
+ endProcData->process = NULL;
+
+ // sync execution: indicate it by negating the pid
+ endProcData->pid = -execData.pid;
+ }
+ else