PDA

View Full Version : QProcess question



PH5
4th February 2010, 23:43
Hi everyone,

The code I am writing uses QProcess to send text to an external script for further processing. I am testing it now with a simple PHP script. The problem I have is that the PHP script doesn't seem to know when I have finished sending text to it.

the last bit of my c code that sends the text does the following:

proc->write("\n");
proc->closeWriteChannel();
}

the PHP script is a command line script that looks like so:


<?php
error_reporting(E_ERROR);

$writefile = fopen($argv[1],'w');
if(!$writefile)
{
echo "Error Opening Text File.\n";
exit;
}
else
{
$stdin = fopen('php://stdin', 'r');
$line = fgets($stdin); // reads one line from STDIN
while(!feof($line))
{
fwrite($writefile,$line);
$line = fgets($stdin); // reads one line from STDIN
}
fwrite("got to here");
}
fclose($writefile);
?>

The script above just captures what is coming in from STDIN and dumps it to a text file. What seems to be happening is that the php script never seems to see the EOF. It never gets out of the while loop. I am at a loss as to which code is misbehaving. Does anyone know if closeWriteChannel() sends out an EOF? If not, is there a way to do so? How can I get my script to recognize that the pipe is closed?

I realize this isn't a PHP help forum, but I had to start looking for help somewhere. Any ideas are greatly appreciated.

Thanks
Paul