A new issue has been created and assigned
to you:
727 - Allow PassThru renderer to push data to program's stdin
Project: Pluf Framework
Status: New
Reported by: Patrick Georgi
Labels:
Priority:Medium
Type:Defect
Description:
I need to call a program which accepts its data via stdin.
To avoid having to build shell scripts on the fly that wrap this program (and finally delete themselves), I extended the renderer to accept php file URIs (including php://stdin, which is important for me), create a temporary file, push its content to the program and finally delete the temporary file.
See attached patch.
Attachments:
- 20110820-1-pluf-stdin-to-passthru.diff - 1.23 kB
http://projects.ceondo.com/p/pluf/issues/view/attachment/281/20110820-1-pluf-stdin-to-passthru.diff
--
Issue: http://projects.ceondo.com/p/pluf/issues/727/
The following issue has been updated:
727 - Allow PassThru renderer to push data to program's stdin
Project: Pluf Framework
Status: New
Reported by: Patrick Georgi
URL: http://projects.ceondo.com/p/pluf/issues/727/
Labels:
Priority:Medium
Type:Defect
Comments (last first):
# By Thomas Keller, Aug 21, 2011:
Basically looks good, a few minor nitpicks:
* consider using $cfg['tmp_folder'] instead of '/tmp' (to which you could however fallback)
* if ($this->infile) is a bit too generic for my taste, better test for null explicitely
* error handling in case file_get_contents($this->infile) fails
* error handling in case file_put_contents() failed and as such a later unlink($name) fails as well
* temp file is not removed in case passthru fails
Pluf's error handler that gets triggered on notices for any of the IO functions probably does the rest, but I'm always a bit dubious about cleaning up the mess properly when it breaks.
# By Patrick Georgi, Aug 20, 2011:
The following issue has been updated:
727 - Allow PassThru renderer to push data to program's stdin
Project: Pluf Framework
Status: New
Reported by: Patrick Georgi
URL: http://projects.ceondo.com/p/pluf/issues/727/
Labels:
Priority:Medium
Type:Defect
Comments (last first):
# By Patrick Georgi, Aug 21, 2011:
The new version uses proc_open, eliminating the issues regarding /tmp and temp files (no temp files in the first place).
$this->infile is now tested explicitely, the file_get/put_contents related code is entirely different now.
Attachments:
- 20110821-1-pluf-stdin-to-passthru.diff - 1.43 kB
http://projects.ceondo.com/p/pluf/issues/view/attachment/283/20110821-1-pluf-stdin-to-passthru.diff
# By Thomas Keller, Aug 21, 2011:
Basically looks good, a few minor nitpicks:
* consider using $cfg['tmp_folder'] instead of '/tmp' (to which you could however fallback)
* if ($this->infile) is a bit too generic for my taste, better test for null explicitely
* error handling in case file_get_contents($this->infile) fails
* error handling in case file_put_contents() failed and as such a later unlink($name) fails as well
* temp file is not removed in case passthru fails
Pluf's error handler that gets triggered on notices for any of the IO functions probably does the rest, but I'm always a bit dubious about cleaning up the mess properly when it breaks.
# By Patrick Georgi, Aug 20, 2011:
I need to call a program which accepts its data via stdin.
The following issue has been updated:
727 - Allow PassThru renderer to push data to program's stdin
Project: Pluf Framework
Status: New
Reported by: Patrick Georgi
URL: http://projects.ceondo.com/p/pluf/issues/727/
Labels:
Priority:Medium
Type:Defect
Comments (last first):
# By Patrick Georgi, Aug 21, 2011:
Forgot to note:
* tested with stdin (git repository access in IDF)
* tested without stdin (git zip export)
* not tested with mod_php, but with php via FastCGI (might make a difference with proc_open)
# By Patrick Georgi, Aug 21, 2011:
The new version uses proc_open, eliminating the issues regarding /tmp and temp files (no temp files in the first place).
$this->infile is now tested explicitely, the file_get/put_contents related code is entirely different now.
Attachments:
- 20110821-1-pluf-stdin-to-passthru.diff - 1.43 kB
http://projects.ceondo.com/p/pluf/issues/view/attachment/283/20110821-1-pluf-stdin-to-passthru.diff
# By Thomas Keller, Aug 21, 2011:
Basically looks good, a few minor nitpicks:
* consider using $cfg['tmp_folder'] instead of '/tmp' (to which you could however fallback)
* if ($this->infile) is a bit too generic for my taste, better test for null explicitely
* error handling in case file_get_contents($this->infile) fails
* error handling in case file_put_contents() failed and as such a later unlink($name) fails as well
* temp file is not removed in case passthru fails
Pluf's error handler that gets triggered on notices for any of the IO functions probably does the rest, but I'm always a bit dubious about cleaning up the mess properly when it breaks.
# By Patrick Georgi, Aug 20, 2011:
I need to call a program which accepts its data via stdin.