php forking/spawning question...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi...

got the follwoing example... basically, when i call the function "spawn_" i
get the passed vars for appname/args...

the $appname,$args are valid when the spawn_ function is initially invoked.
however, when the app does the fork, the $appname, $args get lost. when the
function gets to the pcntl_exec, the vars ($appname, $args) are no longer
set.

so what did i miss, how is this process supposed to work?

thoughts/comments...

thanks


=========================================================================
/*
        test func to spawn client thread
*/
function spawn_($appname, $args)
{
print "appname =".$appname."\n";
print_r($args);
//exit();

        $pid = pcntl_fork();
        if ($pid == -1)
        {
            die('cannot fork');
        }
        elseif ($pid)
        {
                print "child pid = ".$pid."\n";
            //pcntl_waitpid($pid, $status);
                //break;
                //exit();
                $par=1;
        }
        else
        {
            // Note that pcntl_exec() automatically prepends the program
name
            // to the array of arguments; the program name cannot be
spoofed.
                print "running cmd \n";
                 pcntl_exec($appname, $args);
            //system("./clientmgr.php");
                 exit();
        }
}
--------------------------------------------------------------------


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux