Is there any way to get the PID of the process spawned by a curl call? Here's a quick curl call example in foo.php:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, "http://www.foobar.com/bar.php");
$contents = curl_exec($ch);
curl_close($ch);
?>
And I'd like the PID of the bar.php process for use in foo.php. My instincts say there's no way, but figured I'd see if anyone has tried something like that.
If it helps, foo.php and bar.php e开发者_开发知识库xist on the same server.
A call to curl does not spawn a new process, it uses libcurl to make the call from within PHP. For functions related to getting PIDs and such, see the manual section for POSIX Functions. In particular, you may be interested in posix_getpid
or getmypid
. Have bar.php find its own PID, and pass it to foo.php.
精彩评论