#include "wx/thread.h"
#include "wx/process.h"
+#include <sys/wait.h>
+
// Use polling instead of Mach ports, which doesn't work on Intel
// due to task_for_pid security issues.
#if USE_POLLING
+#if wxUSE_THREADS
class wxProcessTerminationEventHandler: public wxEvtHandler
{
public:
return 0;
}
+#else // !wxUSE_THREADS
+int wxAddProcessCallbackForPid(wxEndProcessData*, int)
+{
+ wxLogDebug(wxT("Could not create termination detection thread."));
+ return -1;
+}
+#endif // wxUSE_THREADS/!wxUSE_THREADS
-#else
+#else // !USE_POLLING
#include <CoreFoundation/CFMachPort.h>
-#include <sys/wait.h>
extern "C" {
#include <mach/mach.h>
}
int rc = waitpid(abs(proc_data->pid), &status, WNOHANG);
if(!rc)
{
- wxLogDebug(wxT("Mach port was invalidated, but process hasn't terminated!"));
- return;
+ wxLogDebug(wxT("Mach port was invalidated, but process hasn't terminated!"));
+ return;
}
if((rc != -1) && WIFEXITED(status))
- proc_data->exitcode = WEXITSTATUS(status);
+ proc_data->exitcode = WEXITSTATUS(status);
else
- proc_data->exitcode = -1;
+ proc_data->exitcode = -1;
wxHandleProcessTermination(proc_data);
}
return 0;
}
-#endif // USE_POLLING
+#endif // USE_POLLING/!USE_POLLING
// NOTE: This doesn't really belong here but this was a handy file to
// put it in because it's already compiled for wxCocoa and wxMac GUI lib.