File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -43,20 +43,23 @@ private function readStreams($stdout, $stderr)
4343 {
4444 $ startTime = time ();
4545
46- do {
46+ while ( true ) {
4747 $ this ->output = fread ($ stdout , self ::STREAM_BYTES_PER_READ );
4848 $ this ->error = fread ($ stderr , self ::STREAM_BYTES_PER_READ );
4949
50- $ streamsComplete = (feof ($ stdout ) && feof ($ stderr ));
51-
52- if (!$ streamsComplete ) {
53- // Prevent thrashing.
54- sleep (1 );
50+ if (feof ($ stdout ) && feof ($ stderr )) {
51+ break ;
5552 }
5653
57- $ executionDuration = time () - $ startTime ;
54+ if (time () - $ startTime > self ::EXECUTION_TIMEOUT_SECONDS ) {
55+ throw new RuntimeException (
56+ 'Command execution took over ' .self ::EXECUTION_TIMEOUT_SECONDS .' seconds: ' .$ this ->command
57+ );
58+ }
5859
59- } while ($ executionDuration <= self ::EXECUTION_TIMEOUT_SECONDS && !$ streamsComplete );
60+ // Prevent thrashing
61+ sleep (1 );
62+ }
6063 }
6164
6265 public function getRawOutput (): string
You can’t perform that action at this time.
0 commit comments