Skip to content

Commit 038dd91

Browse files
Fixes #4.
1 parent b75c88e commit 038dd91

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/PipeSys/Scheduler.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ public function run()
9999
if( ( $genResponse = $this->runGen( $key, $readLine ) ) === false )
100100
continue;
101101

102-
$this->handleGenResponse( $genResponse, $key );
102+
// If the pipe is dead then invalidate the command...
103+
if( ! $this->handleGenResponse( $genResponse, $key ) )
104+
$invalidCommands[$key] = true;
103105
}
104106

105107
// If every command is now invalid.
@@ -211,7 +213,16 @@ protected function handleGenResponse($genResponse, $key)
211213
if( $this->commands[$key] === end( $this->commands ) )
212214
$this->stdOut->write( $genResponse );
213215
else
216+
{
217+
// If we are trying to write to a dead pipe return false...
218+
if( isset( $this->commandGenerators[$key + 1] )
219+
&& ! $this->commandGenerators[$key + 1]->valid() )
220+
return false;
221+
214222
$this->buffers[$key]->write( $genResponse );
223+
}
215224
}
225+
226+
return true;
216227
}
217228
}

0 commit comments

Comments
 (0)