On 2013-10-21 4:43 PM, Kristian Evensen wrote:
> From: Kristian Evensen <[email protected]>
>
> uloop_run calls uloop_setup_signals() to set up signal handling before the
> while
> loop, but does not remove the signal handling after the loop has ended. This
> can
> cause problems for for example applications using the ubus file descriptor in
> their own event loops, and perhaps with their own signal handling.
>
> One use-case I experienced was an application that subscribed to several ubus
> objects and used the ubus file descriptor in its own event loop. Even though
> ubus_register_subscriber() (which calls uloop_run()) had returned, the signal
> handler was not removed. This caused SIGINT not to be caught by the
> application.
>
> I am not sure if adding the add variable to uloop_run() is required, or if it
> is
> sufficient to send 0/1 directly.
>
> Signed-off-by: Kristian Evensen <[email protected]>
>
> ---
> uloop.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/uloop.c b/uloop.c
> index 9a0590f..a3e95f7 100644
> --- a/uloop.c
> +++ b/uloop.c
> @@ -556,17 +556,24 @@ static void uloop_sigchld(int signo)
> do_sigchld = true;
> }
>
> -static void uloop_setup_signals(void)
> +static void uloop_setup_signals(uint8_t add)
bool is a more appropriate type here than uint8_t
> {
> struct sigaction s;
>
> memset(&s, 0, sizeof(struct sigaction));
> - s.sa_handler = uloop_handle_sigint;
> + if(add)
> + s.sa_handler = uloop_handle_sigint;
> + else
> + s.sa_handler = NULL;
> s.sa_flags = 0;
> sigaction(SIGINT, &s, NULL);
>
> if (uloop_handle_sigchld) {
> - s.sa_handler = uloop_sigchld;
> + if(add)
> + s.sa_handler = uloop_sigchld;
> + else
> + s.sa_handler = NULL;
> +
> sigaction(SIGCHLD, &s, NULL);
> }
> }
I think you need to use a different approach. What you're doing here
breaks recursive uloop_run calls, which are used in a few places.
You need to change the code to save/restore signal handlers instead of
just setting them to NULL.
- Felix
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel