Fwd: [PHP] How could I mix popen() and pcntl_alarm() function ?
| From: | Chian Hsieh | Date: | Wed, 16 Jun 2010 03:49:09 +0000 |
| Subject: | Fwd: [PHP] How could I mix popen() and pcntl_alarm() function ? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-306188@lists.php.net to get a copy of this message | ||
Hi,
my PHP version is PHP 5.2.4-2.
I was according to the example in page ( pcntl_alarm() function doc page )
http://www.php.net/manual/en/function.pcntl-alarm.php
<http://www.php.net/manual/en/function.pcntl-alarm.php>In
that page,
the register_tick_function()
does not register any function, and it's work on that example in above URI.
In my try and error experiment, I think the SIGALRM does not trigger because
we called popen() function.
Could anyone help ?
Thanks
- Arron
On Wed, Jun 16, 2010 at 2:38 AM, Jim Lucas <lists@cmsws.com> wrote:
> Chian Hsieh wrote:
> > Hi,
> >
> > I want to use tail command to tail the file by popen and trigger the
> > function signal() by every 3 secs.
> >
> > Here is my example code:
> >
> > declare(ticks = 1);
> > // Unreachable function
> > function signal($signal) {
> > echo "SIGALRM\n";
> > pcntl_alarm(3);
> > }
> >
> > pcntl_signal(SIGALRM, "signal");
> > pcntl_alarm(3);
> > $fpcmd = popen("tail -f my.log", 'r');
> > while (!feof($fpcmd)) {
> > $line = fgets($fpcmd);
> > echo $line;
> > }
> >
> >
> > Unfortunately, the signal() function is never reached.
> > Why ? Could someone help me ?
> >
> > Thanks for your help.
> >
> > - Arron
> >
>
> What version of PHP are you running?
>
> Read: http://php.net/declare
>
> I found this at the bottom of the declare page.
>
> [quote]
> The encoding declare value is ignored in PHP 5.3 unless php is compiled
> with
> --enable-zend-multibyte.
> [/quote]
>
> Also, doesn't look like you are using the "register_tick_function()"
> function.
>
> Is it required? Not sure, but their examples show its usage.
>
> --
> Jim Lucas
>
> A: Maybe because some people are too annoyed by top-posting.
> Q: Why do I not get an answer to my question(s)?
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>
--
- Chi-An Hsieh
--
- Chi-An Hsieh