ext-uv/examples/spawn.php

35 lines
668 B
PHP
Raw Normal View History

2012-06-14 22:29:16 +09:00
<?php
$out = uv_pipe_init(uv_default_loop,0);
2012-06-15 23:29:36 +09:00
$process = uv_spawn(uv_default_loop(), "php", array('-r','var_dump($_ENV);'), array(
2012-06-14 23:07:12 +09:00
"cwd" => "/usr/bin/",
2012-06-14 22:29:16 +09:00
"pipes" => array(
$out,
2012-06-15 22:47:46 +09:00
),
"env" => array(
"KEY" => "VALUE",
"HELLO" => "WORLD",
2012-06-14 22:29:16 +09:00
)
2012-06-14 23:07:12 +09:00
),function($process, $stat, $signal){
2012-06-14 22:29:16 +09:00
echo "spawn_close_cb\n";
var_dump($process);
var_dump($stat);
var_dump($signal);
uv_close($process,function(){
echo "close";
});
});
uv_read_start($out,function($buffer,$stat) use ($out){
var_dump($out);
var_dump($stat);
var_dump($buffer);
uv_close($out,function(){
});
});
uv_run();