xref: /php-uv/examples/spawn_fd.php (revision 99312394)
1<?php
2
3$in  = uv_pipe_init(uv_default_loop(), true);
4
5echo "HELLO ";
6
7$stdio = array();
8$stdio[] = uv_stdio_new($in, UV::CREATE_PIPE | UV::READABLE_PIPE);
9
10$fp = fopen("php://stdout", "w");
11$stdio[] = uv_stdio_new($fp, UV::INHERIT_FD | UV::WRITABLE_PIPE);
12
13$flags = 0;
14uv_spawn(uv_default_loop(), "php", ['-r', 'var_dump($_ENV);'], $stdio, "/usr/bin/",
15    ["key" => "hello"],
16    function($process, $stat, $signal){
17	    uv_close($process,function(){});
18
19    }, $flags);
20
21uv_run();
22