ext-uv/examples/spawn.php

40 lines
750 B
PHP
Raw Normal View History

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