Skip to content

Instantly share code, notes, and snippets.

@rococodogs
Created February 15, 2015 17:44
Show Gist options
  • Save rococodogs/46a0c8234e26ad8eb6ee to your computer and use it in GitHub Desktop.
Save rococodogs/46a0c8234e26ad8eb6ee to your computer and use it in GitHub Desktop.
spelling out how to use php's proc
<?php
$process = proc_open(
'wc', // cmd to run
// define yr pipes
[
['file', __FILE__, 'r'], // stdin (passing file to wc)
['file', 'output.txt' , 'w'] // stdout (output, we could also echo stream_get_contents of $pipes[1])
],
// var to store the above
$pipes
);
if ( is_resource($process) ) {
// since we don't need to push anything in to stdin, we'll close the process
$return = proc_close($process);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment