shell_exec()
does not return a handle. It returns the output of a command. So, you'd see STDOUT and STDERR in $handle
. I would stop this and instead only echo $!
, which will be set as PID of the last executed command. This PID you can then pass to kill
to properly kill xulrunner.exe
So, to sum it up:
$toExecute = "<path>/xulrunner.exe <params> >/dev/null 2>/dev/null & echo $!";
$myPid = shell_exec( $toExecute );
...
exec( "/bin/kill $myPid" );
Note that for safety you should use escapeshellarg()
and escapeshellcmd()
where appropriate. Otherwise you are exposing yourself to shenanigans.