Fwd: [PHP] Exec Script in the background, don't wait till it finishes
| From: | Evil Son | Date: | Fri, 14 Jan 2011 18:31:18 +0000 |
| Subject: | Fwd: [PHP] Exec Script in the background, don't wait till it finishes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310767@lists.php.net to get a copy of this message | ||
Sorry, not sent to the list.
---------- Forwarded message ----------
From: Evil Son <ewilsonmail@gmail.com>
Date: Sat, Jan 15, 2011 at 4:26 AM
Subject: Re: [PHP] Exec Script in the background, don't wait till it finishes
To: Kai Renz <writemecas@googlemail.com>
On Sat, Jan 15, 2011 at 2:56 AM, Kai Renz <writemecas@googlemail.com> wrote:
> Hi there,
>
> i'm currently working on a socket project. It consists of two scripts.
> The first script (socket1.php) creates a socket on a specified port
> and waits for a client to connect. If a client connects, they exchange
> some informations, including a random created port. Next, the first
> script calls the second script (socket2.php) with the just created
> port number as a parameter.
>
> Now here is the problem:
> it all works fine, but the client can't send a quit message to socket1
> because socket1.php waits until socket2.php is finished. socket2.php
> is working properly, and if i connect to the new socket and quit the
> connection, socket1 is working again. All i need socket1 to do is to
> continue working independant of socket2.
>
> I tried everything, from shell_exec to pcntl_exec, nothing seems to work.
Looking at the manual, shell_exec will wait for the other script to
return (just like calling the 2nd script"), pcntl_exec replaces the
original server with the new one. pcntl_fork is what you want but it
is non-windows. Hopefully you are running on *nix.
HTH
--
Regards
Evil Son
--
Regards
Evil Son