michael...

i had tried earlier to implement what you had seen.

my attempt (below) never seemed to work properly...

php -r 'exec("perl /home/test/college.pl /dev/null 2>&1 &");' <<< works, but
doesn't return until the perl app completes...


php -r 'exec("bash -c 'exec nohup perl /home/test/college.pl /dev/null 2>&1
&'");' <<< can't get this to work/return....

any ideas as to what i'm missing...

thanks

-bruce


-----Original Message-----
From: Michael Sims [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 21, 2004 11:16 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] exec/system question..


Justin Patrin wrote:
> On Wed, 21 Jul 2004 10:09:52 -0700, bruce <[EMAIL PROTECTED]>
> wrote:
>> 2) i could run the perl script, and have it somehow run in the
>> background.... this would ba good, if there's a way to essentially
[...]
> AFAIK there's no way to do this. When the request ends (user hits
> stop, exit or die called) the process is ended. This includes
> children.

There are ways around that, though, at least if you're running unix:

exec('bash -c "exec nohup setsid your_command > /dev/null 2>&1 &"');

I found this method in a user contributed note underneath the documentation
for
exec() and it works rather well.  The exec call returns very quickly and the
child
process continues to run even after the parent process dies.  The important
part of
the above command is "nohup" which runs a command that ignores hangup
signals.

> If you could set it off asynchronously, there would be no
> way of knowing when it ended as the process wouldn't have access to
> that session any more.

If the OP could reimplement his perl script in PHP it could be passed the
session ID
as an argument.  The child process could then call session_id($argv[1])
before
calling session_start(), and finally update the session data to indicate its
current
status.

If that's out of the question the perl script could update its status in a
database
table as you suggested...

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

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

Reply via email to