[Cmake-commits] [cmake-commits] king committed ProcessUNIX.c 1.74 1.75

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Aug 20 09:57:11 EDT 2008


Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv16135/Source/kwsys

Modified Files:
	ProcessUNIX.c 
Log Message:
BUG: Handle case when select() lies

According to "man select" on Linux it is possible that select() lies
about data being ready on a pipe in some subtle cases.  We deal with
this by switching to non-blocking i/o and checking for EAGAIN.  See
issue #7180.


Index: ProcessUNIX.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/ProcessUNIX.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -C 2 -d -r1.74 -r1.75
*** ProcessUNIX.c	13 May 2008 09:18:51 -0000	1.74
--- ProcessUNIX.c	20 Aug 2008 13:57:09 -0000	1.75
***************
*** 771,775 ****
      }
  
! #if !KWSYSPE_USE_SELECT
    if(!kwsysProcessSetNonBlocking(p[0]))
      {
--- 771,776 ----
      }
  
!   /* Set to non-blocking in case select lies, or for the polling
!      implementation.  */
    if(!kwsysProcessSetNonBlocking(p[0]))
      {
***************
*** 778,782 ****
      return;
      }
- #endif
    }
  
--- 779,782 ----
***************
*** 831,842 ****
        }
  
! #if !KWSYSPE_USE_SELECT
!     /* Set the output pipe of the last process to be non-blocking so
!        we can poll it.  */
!     if(i == cp->NumberOfCommands-1 && !kwsysProcessSetNonBlocking(readEnd))
        {
        failed = 1;
        }
- #endif
  
      if(failed)
--- 831,840 ----
        }
  
!     /* Set the output pipe of the last process to be non-blocking in
!        case select lies, or for the polling implementation.  */
!     if(i == (cp->NumberOfCommands-1) && !kwsysProcessSetNonBlocking(readEnd))
        {
        failed = 1;
        }
  
      if(failed)
***************
*** 1058,1061 ****
--- 1056,1064 ----
            }
          }
+       else if(n < 0 && errno == EAGAIN)
+         {
+         /* No data are really ready.  The select call lied.  See the
+            "man select" page on Linux for cases when this occurs.  */
+         }
        else
          {



More information about the Cmake-commits mailing list