从php中的exec()获取pid

I need to exec a script using exec() and get the pid back.

$pid = exec("./runtunnel $remoteip $remoteport $localport");

Actuall code for execute command is here:

exec ( string $command [, array &$output [, int &$return_var ]] )

so to get output you need to add second argument:

$pid = exec("./runtunnel $remoteip $remoteport $localport",$output);

$output will have the output.

reference.

in unix, you can add this to get only the PID:

$command = $yourCommand.' > /dev/null 2>&1 & echo $!'; 
exec($command ,$output);
$pid = (int)$op[0];

hope that will be helpful :)