What's happening is that I'm using PHP to perform remote executions of a specific Bash file whereby I take the console information and use fgets to display it to the browser window. Most of the time, this seems to work without major issues but the warning above makes me wonder. Every time I see it, it's always coming from the following line of code:Warning: fgets(): Failure 'transport read' (-43) in C:\www\practice\foobar\test.php on line 66
Code: Select all
$line = fgets($stdout_stream);Code: Select all
if($stream){
$results = array();//Holds errors, warnings, and other notifications...
$stdout_stream = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
if (ob_get_level() == 0)
ob_start();
$max_time = 7200;//Allow a 2 hour max Bash execution!!! (We can allow more if necessary...)
$timer = 1;
while(!feof($stdout_stream)){
$line = fgets($stdout_stream);//TODO: Fix "Warning: fgets(): Failure 'transport read' (-43)" message...
if($line !== false){
if(trim($line) !== ''){
//General FATAL Condition...
if(strpos($line, 'Fatal') !== false){
print 'A fatal outcome has been trapped for '.$id.'!';
}
//"Not found" Condition...
if(strpos($line, 'The specified ID cannot be found') !== false){
print 'ID '.$id.' was not found in Blackboard!';
}
}
}else{
/*
This ELSE condition checks timer against a stalled "ls" stream. If it goes beyond $max_time, we terminate.
(Otherwise, if this wasn't here, it would go into an infinite stream due to how the faulty feof acts.)
*/
$timer++;
sleep(1);
if($timer == $max_time){
//Try to eject if the $max_time is met...
print 'The archive function could not create the archive and decided to give up (processing went over 2 hours). This is likely due to having a very large amount of content. This ID will be skipped. Continuing...';
break;
}
}
@ob_flush();//This can sometimes be empty, revealing nasty notice verbiage... The '@' suppresses this but still allows it to run.
flush();
usleep(1);
}
fclose($stdout_stream);
@ob_end_flush();
print 'Finished executing archives!';
return $results;
}Long story short, I'm just not sure how to track down the meaning behind "Warning: fgets(): Failure 'transport read' (-43)". I'm not certain, but I guess it could be caused by needing more time to complete?
If anyone could shine some light on this, I would be especially grateful. Thanks in advance.