]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/corefoundation/utilsexc_cf.cpp
Fix a number of problems with tracking rectangles by avoiding rebuilding them when...
[wxWidgets.git] / src / mac / corefoundation / utilsexc_cf.cpp
index a8db1a3c853bc146d887700b8d02659b7ac86b29..ca17d2da39d6885aa0e157714a2d1708f2d22ec4 100644 (file)
 #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.
 
+// http://developer.apple.com/technotes/tn/tn2050.html
+
 // What's a better test for Intel vs PPC?
 #ifdef WORDS_BIGENDIAN
 #define USE_POLLING 0
@@ -33,6 +37,7 @@
 
 #if USE_POLLING
 
+#if wxUSE_THREADS
 class wxProcessTerminationEventHandler: public wxEvtHandler
 {
   public:
@@ -77,7 +82,7 @@ void* wxProcessTerminationThread::Entry()
     {
         usleep(100);
         int status = 0;
-        int rc = waitpid(abs(m_data->pid), & status, WNOHANG);
+        int rc = waitpid(abs(m_data->pid), & status, 0);
         if (rc != 0)
         {
             if ((rc != -1) && WIFEXITED(status))
@@ -115,11 +120,17 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid)
 
     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>
 }
@@ -132,13 +143,13 @@ void wxMAC_MachPortEndProcessDetect(CFMachPortRef port, void *data)
     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);
 }
 
@@ -210,17 +221,19 @@ int wxAddProcessCallbackForPid(wxEndProcessData *proc_data, int pid)
     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.
 #if wxUSE_GUI
 
+#if wxUSE_STDPATHS
 static wxStandardPathsCF gs_stdPaths;
 wxStandardPathsBase& wxGUIAppTraits::GetStandardPaths()
 {
     return gs_stdPaths;
 }
+#endif
 
 #endif // wxUSE_GUI