Skip to content
Snippets Groups Projects
Commit 83f5fa50 authored by Brad King's avatar Brad King
Browse files

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.
parent b1f66ef4
No related branches found
No related tags found
No related merge requests found
......@@ -770,14 +770,14 @@ void kwsysProcess_Execute(kwsysProcess* cp)
return;
}
#if !KWSYSPE_USE_SELECT
/* Set to non-blocking in case select lies, or for the polling
implementation. */
if(!kwsysProcessSetNonBlocking(p[0]))
{
kwsysProcessCleanup(cp, 1);
kwsysProcessCleanupDescriptor(&si.StdErr);
return;
}
#endif
}
/* Replace the stderr pipe with a file if requested. In this case
......@@ -830,14 +830,12 @@ void kwsysProcess_Execute(kwsysProcess* cp)
failed = 1;
}
#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))
/* 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;
}
#endif
if(failed)
{
......@@ -1057,6 +1055,11 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
return 1;
}
}
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
{
/* We are done reading from this pipe. */
......
......@@ -4,7 +4,7 @@
SET(KWSYS_DATE_STAMP_YEAR 2008)
# KWSys version date month component. Format is MM.
SET(KWSYS_DATE_STAMP_MONTH 07)
SET(KWSYS_DATE_STAMP_MONTH 08)
# KWSys version date day component. Format is DD.
SET(KWSYS_DATE_STAMP_DAY 10)
SET(KWSYS_DATE_STAMP_DAY 20)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment