Markus Duft wrote:
> Hi all!
> 
[snip]
> 
> i thought of introducing some lame timeout when select()ing the signal
> pipe, then checking whether the process is still alive (wait()), and
> again selecting if it is. what do you think?

answering my own mail, i came up with a patch in the meantime, which
seems to fix the problem... however, i'm not sure whether i'm doing
something completely dumb, which may confuse cmake internally somehow.
could some of you guys who have the power(tm) have a look at the
attached patch (cmake-2.6.4-interix-parallel.patch) and tell me what you
think? again: this is just to get it working on multi-core machines.
single-core works already... (it required the (also attached)
cmake-2.6.0-interix.patch to get this far).

as you may have deduced from the patch name already, i'm using 2.6.4
(forgot to mention that - sorry).

BTW: if somebody feels like accepting the two patches i'd be more than
glad. do you need a bug report for that?

Cheers, Markus

> 
> one more word to say: although interix is running on top of the windows
> kernel, i don't have access to the win32 api, so i can't reuse the win32
> code.
> 
> the second problem i have is regarding a broken select(). i tried to
> work around it by setting KWSYSPE_USE_SELECT, which initially didn't
> work, because the code seems b0rked. it seems that there is a wrong
> timeout check in that code path. first kwsysProcessGetTimeoutLeft is
> called, like in the select() code path, but directly after that, the
> timeoutLength members are checkd seperately once more. with this check
> it seems that all sub-processes "time out" immediately. if i comment
> this check, it works fine (although the above random SIGCHLD propblem
> persists of course).
> 
> Need more info? I'll be glad to provide it ;)
> 
> Thanks in advance for taking the time to help!
> 
> Cheers, Markus
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
> 

diff -ruN cmake-2.6.0.orig/Modules/Platform/Interix.cmake 
cmake-2.6.0/Modules/Platform/Interix.cmake
--- cmake-2.6.0.orig/Modules/Platform/Interix.cmake     1970-01-01 01:00:00 
+0100
+++ cmake-2.6.0/Modules/Platform/Interix.cmake  2008-06-02 14:22:45 +0200
@@ -0,0 +1,31 @@
+# This is a proposed Platform definition for Interix GCC/G++
+
+SET(CMAKE_DL_LIBS "dl")
+SET(CMAKE_SHARED_LIBRARY_C_FLAGS "")
+SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
+SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
+SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
+SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-h,")
+SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-h,")
+
+SET(UNIX 1)
+
+# also add the install directory of the running cmake to the search directories
+# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels 
up
+GET_FILENAME_COMPONENT(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
+GET_FILENAME_COMPONENT(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
+
+LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH
+       "${_CMAKE_INSTALL_DIR}"
+       "${CMAKE_INSTALL_PREFIX}"
+       )
+
+LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH
+       "${CMAKE_INSTALL_PREFIX}"/include
+       )
+
+LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+       "${CMAKE_INSTALL_PREFIX}"/lib
+       )
+
diff -ruN cmake-2.6.0.orig/Utilities/cmtar/encode.c 
cmake-2.6.0/Utilities/cmtar/encode.c
--- cmake-2.6.0.orig/Utilities/cmtar/encode.c   2008-06-02 13:00:44 +0200
+++ cmake-2.6.0/Utilities/cmtar/encode.c        2008-06-02 14:02:39 +0200
@@ -24,6 +24,9 @@
 # include <stdlib.h>
 #endif
 
+#ifdef HAVE_SYS_MKDEV_H
+# include <sys/mkdev.h>
+#endif
 
 /* magic, version, and checksum */
 void
diff -ru cmake-2.6.4.orig/Source/kwsys/ProcessUNIX.c 
cmake-2.6.4/Source/kwsys/ProcessUNIX.c
--- cmake-2.6.4.orig/Source/kwsys/ProcessUNIX.c 2010-02-17 14:39:20 +0100
+++ cmake-2.6.4/Source/kwsys/ProcessUNIX.c      2010-02-17 15:52:30 +0100
@@ -1018,6 +1018,9 @@
   int numReady = 0;
   int max = -1;
   kwsysProcessTimeNative* timeout = 0;
+#ifdef __INTERIX
+  int is_sig_only = 0;
+#endif
 
   /* Check for any open pipes with data reported ready by the last
      call to select.  According to "man select_tut" we must deal
@@ -1125,9 +1128,65 @@
 
   /* Run select to block until data are available.  Repeat call
      until it is not interrupted.  */
+#ifdef __INTERIX
+  /* hack around broken sh** ... */
+  is_sig_only = 1;
+  for(i=0; i < KWSYSPE_PIPE_COUNT; ++i) {
+       if(cp->PipeReadEnds[i] >= 0) {
+               if(i != KWSYSPE_PIPE_SIGNAL)
+                       is_sig_only = 0;
+       } else {
+               if(i == KWSYSPE_PIPE_SIGNAL)
+                       is_sig_only = 0;
+       }
+  }
+
+  if(is_sig_only && !timeout) {
+       static kwsysProcessTimeNative _tmp = { 1,0 };
+       timeout = &_tmp;
+  }
+
+  while(1) {
+#endif
+
   while(((numReady = select(max+1, &cp->PipeSet, 0, 0, timeout)) < 0) &&
         (errno == EINTR));
 
+#ifdef __INTERIX
+       if(!is_sig_only)
+               break;
+       
+       if(numReady != 0)
+               break;
+               
+       /* only signal pipe left over, and nothing waiting ...
+        * we'll just wait() for the process to see whether it still exists.
+        * if it does, we continue to select, otherwise we return 0. no need
+        * to modify the PipeSet as the pipe will be set in there anyway then. 
*/
+       for(i=0; i < cp->NumberOfCommands; ++i)
+    {
+    if(cp->ForkPIDs[i])
+      {
+      int result;
+      while(((result = waitpid(cp->ForkPIDs[i],
+                               &cp->CommandExitCodes[i], WNOHANG)) < 0) &&
+            (errno == EINTR));
+      if(result == cp->ForkPIDs[i])
+        {
+                       /* uh ... process terminated, SIGCHLD got lost?
+                        * what should i DO here? */
+
+                       /* Set the pipe in a signalled state.  */
+                       kwsysProcessCleanupDescriptor(&cp->SignalPipe);
+                       return 1;
+        }
+      }
+    }
+       /* no process terminated, nothing select()ed. */
+       continue;
+  }
+#endif
+
   /* Check result of select.  */
   if(numReady == 0)
     {
@@ -1215,12 +1274,16 @@
     return 1;
     }
 
+/* errr.... this looks wrong, and is not done for the select() part above.
+ * (the kwsysProcessGetTimeoutLeft part from above is in both code paths).  */
+#if 0
   if((timeoutLength.tv_sec == 0) && (timeoutLength.tv_usec == 0))
     {
     /* Timeout has already expired.  */
     wd->Expired = 1;
     return 1;
     }
+#endif
 
   /* Sleep a little, try again. */
   {
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to