# Replacement to ticks for signals

- Thread: https://externals.io/message/39374
- Original archive: https://news-web.php.net/php.internals/39374
- Started by Arnaud Le Blanc on 2008-07-27T13:51:30+00:00
- Messages: 10
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #39374 — Arnaud Le Blanc — 2008-07-27T13:51:30+00:00

URL: https://externals.io/message/39374#39374

Hi,

I made a `pcntl_signal_dispatch()` function [1] to allow scripts that use 
signals to work without ticks.

This function just calls the pcntl's tick handler on-demand so that all signal 
handler functions are called if there are pending signals.

It does not allow the signal handlers to be called at any time like with 
ticks, but allows things like this:

while (do_something()) {
 /* main loop */
 `pcntl_signal_dispatch()`;
}

or 

while (pcntl_signal_dispatch() && do_something()) {
 /* main loop */
}

Can I commit this ?

[1] http://arnaud.lb.s3.amazonaws.com/pcntl_signal_dispatch.patch

Regards,

Arnaud

---

## #39375 — Derick Rethans — 2008-07-27T14:04:58+00:00

URL: https://externals.io/message/39374#39375 · In reply to: #39374

> Hi,
> 
> I made a `pcntl_signal_dispatch()` function [1] to allow scripts that use 
> signals to work without ticks.
> 
> This function just calls the pcntl's tick handler on-demand so that all signal 
> handler functions are called if there are pending signals.
> 
> It does not allow the signal handlers to be called at any time like with 
> ticks, but allows things like this:
> 
> while (do_something()) {
>  /* main loop */
>  `pcntl_signal_dispatch()`;
> }
> 
> or 
> 
> while (pcntl_signal_dispatch() && do_something()) {
>  /* main loop */
> }

Does the function block if there are no pending signals? If not, I think 
we should make that an option.

regards,
Derick

-- 
HEAD before 5_3!: http://tinyurl.com/6d2esb
http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org

---

## #39382 — Arnaud Le Blanc — 2008-07-27T14:38:47+00:00

URL: https://externals.io/message/39374#39382 · In reply to: #39375

On Sunday 27 July 2008 16:04:58 Derick Rethans wrote:
> 
> 
> > […]
signal 
> > […]
> 
> Does the function block if there are no pending signals? If not, I think 
> we should make that an option.
> 

No, but I was thinking to implement sigwaitinfo()/sigtimedwait(), which blocks 
indefinitly or for a given time until a signal is delivered. This also 
requires to implement sigprocmask().

It would also be great to have signalfd() (which is select()able), but it's 
Linux specific and requires quite recent Kernel and libc (that said, I'm 
going to implement it if there are positive feedbacks about that).

Regards,

Arnaud

---

## #39410 — Arnaud Le Blanc — 2008-07-28T15:26:39+00:00

URL: https://externals.io/message/39374#39410 · In reply to: #39382

On Sunday 27 July 2008 16:38:47 Arnaud Le Blanc wrote:
> On Sunday 27 July 2008 16:04:58 Derick Rethans wrote:
> > […]
> signal 
> > […]
> 
> No, but I was thinking to implement sigwaitinfo()/sigtimedwait(), which 
blocks 
> indefinitly or for a given time until a signal is delivered. This also 
> requires to implement sigprocmask().
> 
> It would also be great to have signalfd() (which is select()able), but it's 
> Linux specific and requires quite recent Kernel and libc (that said, I'm 
> going to implement it if there are positive feedbacks about that).
> 

I added `pcntl_sigwaitinfo()`, `pcntl_sigtimedwait()` and `pcntl_sigprocmask()` to 
my patch:

http://arnaud.lb.s3.amazonaws.com/pcntl.patch

 `pcntl_sigwaitinfo()` allows to block until the specified signals have been 
delivered.
 `pcntl_sigtimedwait()` does the same thing, but with a timeout.
 `pcntl_sigprocmask()` allows to block a set of signals so that they will not be 
delivered between two calls of the above functions.

---

## #39435 — Arnaud Le Blanc — 2008-07-29T14:28:22+00:00

URL: https://externals.io/message/39374#39435 · In reply to: #39410

On Monday 28 July 2008 17:26:39 Arnaud Le Blanc wrote:
> On Sunday 27 July 2008 16:38:47 Arnaud Le Blanc wrote:
> > […]
use 
> > […]
all 
> > […]
with 
> > […]
> blocks 
> > […]
it's 
> > […]
> 
> I added `pcntl_sigwaitinfo()`, `pcntl_sigtimedwait()` and `pcntl_sigprocmask()` to 
> my patch:
> 
> http://arnaud.lb.s3.amazonaws.com/pcntl.patch
> 
> `pcntl_sigwaitinfo()` allows to block until the specified signals have been 
> delivered.
> `pcntl_sigtimedwait()` does the same thing, but with a timeout.
> `pcntl_sigprocmask()` allows to block a set of signals so that they will not 
be 
> delivered between two calls of the above functions.

Lukas, Johannes, can I ? (As this is to give an alternative to a deprecated 
feature).

Regards,

Arnaud

---

## #39436 — Antony Dovgal — 2008-07-29T14:40:03+00:00

URL: https://externals.io/message/39374#39436 · In reply to: #39435

> > […]
> be 
> > […]
> 
> Lukas, Johannes, can I ? (As this is to give an alternative to a deprecated 
> feature).

Could you separate the ticks/dispatch patch from the new functions, please?
I just think they are two separate things and therefore should committed in two steps.
Other than that, I don't have any objections.

-- 
Wbr, 
Antony Dovgal

---

## #39437 — Lukas Kahwe Smith — 2008-07-29T14:55:12+00:00

URL: https://externals.io/message/39374#39437 · In reply to: #39436

> 
> > […]
>
> Could you separate the ticks/dispatch patch from the new functions,  
> please?
> I just think they are two separate things and therefore should  
> committed in two steps.
> Other than that, I don't have any objections.


Then go ahead and commit according to the notes by Tony.
We will then keep the deprecation flags as is in HEAD and 5.3.
Could you also update the http://wiki.php.net/doc/scratchpad/upgrade/ 
53 page?

regards,
Lukas Kahwe Smith
mls@pooteeweet.org

---

## #39439 — Arnaud Le Blanc — 2008-07-29T16:31:56+00:00

URL: https://externals.io/message/39374#39439 · In reply to: #39436

On Tuesday 29 July 2008 16:40:03 Antony Dovgal wrote:
> 
> > […]
to 
> > […]
not 
> > […]
deprecated 
> > […]
> 
> Could you separate the ticks/dispatch patch from the new functions, please?
> I just think they are two separate things and therefore should committed in 
two steps.
> Other than that, I don't have any objections.
> 
> -- 
> Wbr, 
> Antony Dovgal
> 

Yes, no problem, I will commit them separately :)

---

## #39440 — Arnaud Le Blanc — 2008-07-29T16:32:39+00:00

URL: https://externals.io/message/39374#39440 · In reply to: #39437

On Tuesday 29 July 2008 16:55:12 Lukas Kahwe Smith wrote:
> 
> 
> 
> > […]
> 
> 
> Then go ahead and commit according to the notes by Tony.
> We will then keep the deprecation flags as is in HEAD and 5.3.
> Could you also update the http://wiki.php.net/doc/scratchpad/upgrade/ 
> 53 page?
> 
> regards,
> Lukas Kahwe Smith
> mls@pooteeweet.org
> 
> 
> 
> 

Thanks :) 
Ok for the wiki, I will update it.

---

## #39441 — Antony Dovgal — 2008-07-29T16:35:41+00:00

URL: https://externals.io/message/39374#39441 · In reply to: #39439

> > […]
> two steps.
> > […]

> Yes, no problem, I will commit them separately :) 

Thanks a lot!

-- 
Wbr, 
Antony Dovgal
