Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider as uri if it is not a resource #20

Merged
merged 3 commits into from
Nov 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/CmdExecuteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ public function execute($cmd, $data)
$cmd = escapeshellcmd($cmd);
$process = proc_open($cmd, $descr, $pipes);

// Stream input to STDIN
while (!feof($data)) {
fwrite($pipes[0], fread($data, 1024));
}
// Get the data into pipe only if data is resource
if (gettype($data) == "resource") {
// Stream input to STDIN
while (!feof($data)) {
fwrite($pipes[0], fread($data, 1024));
}

// Close STDIN and the source data.
fclose($pipes[0]);
fclose($data);
// Close STDIN and the source data.
fclose($pipes[0]);
fclose($data);
}

// Wait for process to finish while reading STDOUT to a temp stream.
// Otherwise the process can block indefinitely if STODUT gets bigger
Expand Down