Created
June 15, 2010 15:37
-
-
Save clairvy/439270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env php | |
| <?php | |
| $stdout = fopen('php://stdout', 'w'); | |
| $stderr = fopen('php://stderr', 'w'); | |
| fwrite($stdout, "Hello stdout\n"); | |
| fwrite($stderr, "Hello stderr\n"); | |
| sleep(100); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env php | |
| <?php | |
| function f() { | |
| $descriptorspec = array( | |
| array('pipe', 'r'), | |
| array('pipe', 'w'), | |
| array('pipe', 'w'), | |
| ); | |
| $process = proc_open('./out.php', $descriptorspec, $pipes); | |
| $ret = pcntl_waitpid(proc_get_pid($process), $status, WNOHANG); | |
| echo "ret = $ret\n"; | |
| echo "close\n"; | |
| //proc_close($process); | |
| $ret = posix_kill(proc_get_pid($process), SIGTERM); | |
| echo "ret = $ret\n"; | |
| echo "wait\n"; | |
| while (pcntl_waitpid(proc_get_pid($process), $status) <= 0) { | |
| } | |
| $ret = proc_close($process); | |
| echo "ret = $ret\n"; | |
| } | |
| function proc_get_pid($process) { | |
| $status = proc_get_status($process); | |
| return $status['pid']; | |
| } | |
| f(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
考えながら書いてるのでコードは汚い.