[PHP] Re: Drop connection, keep running?

2002-07-02 Thread Richard Lynch

>
>I'm surprized I can't find a description of how to do what seems
>like an obvious thing to me: I want to have my script send output
>to the user, then drop the connection, and then continue doing
>stuff that the user shouldn't have to wait for.  There's lots of
>documentation about what to do when the user drops, but no mention
>of how to make the server drop it but keep running the script.

http://php.net/exec and put an & at the end...

However, *IF* your script messes with stdin and/or stdout, that may not be
enough, and you have to muck with making a stub script that has the & in it,
and then PHP calls the script that forks the script that does the work.

I never did quite track down when you could or couldn't just throw & into an
exec() call, but it's somehow tied to the binding of stdin and stdout by
Apache, PHP, the shell, the PHP user and their environment (or lack thereof)
and...  Well, I was getting a headache, and a one-line shell script to do
the & for me was better than taking more aspirin.

Hope I'm making sense.  It's getting late and I should sleep now.

-- 
Like Music?  http://l-i-e.com/artists.htm


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




[PHP] [lee@piclab.com: Re: [PHP] Re: Drop connection, keep running?]

2002-07-01 Thread Lee Daniel Crocker

> (Chris Shiflett <[EMAIL PROTECTED]>):
> John Wulff wrote:
> 
> I have never heard of someone wanting to do this, but you might want to 
> look into methods of executing shell commands in the background, which 
> seems like it should be possible. Basically, you're wanting to execute 
> something that immediately returns control back to your PHP script. The 
> PHP script *must* complete before it will be "finished" from the Web 
> server's perspective. Thus, you'll have to at least split up the logic 
> you want to do later into a separate script and just figure out how to 
> get that running just before your script terminates. If it's written in 
> PHP, don't forget about the CLI; it might come in handy for you in this 
> case.
> 
> Let us know what you come up with.

Yeah, I could do that but I don't really want to spawn a whole process
and copy over all the data that's there already.  In a Java servlet
this is a piece of cake--you just spin off a thread to do the work and
return from the request thread.  Here I'd want to do something like a
fork(), then exit the parent and do some processing in the child.

The PHP manual says that the pcntl() functions (which include forking)
are not available from with a web server context, so I guess Apache
doesn't like its modules forking off demons.

-- 
Lee Daniel Crocker <[EMAIL PROTECTED]> 
"All inventions or works of authorship original to me, herein and past,
are placed irrevocably in the public domain, and may be used or modified
for any purpose, without permission, attribution, or notification."--LDC

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




Re: [PHP] Re: Drop connection, keep running?

2002-06-28 Thread Joshua Alexander

This sounds like the right track to me... the script has to finish 
for the page to stop loading, yes? So exec("your_other_script &"); 
and be done with it, yes?

>I have never heard of someone wanting to do this, but you might want 
>to look into methods of executing shell commands in the background, 
>which seems like it should be possible. Basically, you're wanting to


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