[PATCH] device: avoid signals sent to the mbim-proxy process

Aleksander Morgado aleksander at aleksander.es
Tue Aug 8 07:53:01 UTC 2017


On Sun, Aug 6, 2017 at 1:13 PM, Aleksander Morgado
<aleksander at aleksander.es> wrote:
> If e.g. mbim-proxy is started by ModemManager and we send a Ctrl+C to
> it, the signal would be propagated to the mbim-proxy process and we
> would kill it right away, while leaving ModemManager still around
> wondering why the socket to the proxy got a HUP.
>
> Avoid this, by making sure the mbim-proxy gets its own process group.
> ---
>
> Hey,
>
> Eric, adding you in CC because I got this issue while testing your ModemManager patch to act on proxy crashes. I was running MM in --debug mode and sent a Ctrl-C to stop it, and that actually ended up killing the proxy underneath and your reprobe logic hitting in... :)
>
> What do you guys think? I believe this is reasonable, the proxy should really be a complete independent spawn not tied to the process which originated it.
>
> The same change would be applicable to qmi-proxy.
>

Pushed to git master, and will port the change to libqmi as well.

> ---
>  src/libmbim-glib/mbim-device.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/src/libmbim-glib/mbim-device.c b/src/libmbim-glib/mbim-device.c
> index 68544af..4b7d431 100644
> --- a/src/libmbim-glib/mbim-device.c
> +++ b/src/libmbim-glib/mbim-device.c
> @@ -1077,6 +1077,13 @@ wait_for_proxy_cb (GTask *task)
>  }
>
>  static void
> +spawn_child_setup (void)
> +{
> +    if (setpgid (0, 0) < 0)
> +        g_warning ("couldn't setup proxy specific process group");
> +}
> +
> +static void
>  create_iochannel_with_socket (GTask *task)
>  {
>      MbimDevice *self;
> @@ -1138,7 +1145,7 @@ create_iochannel_with_socket (GTask *task)
>                              argc,
>                              NULL, /* envp */
>                              G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
> -                            NULL, /* child_setup */
> +                            (GSpawnChildSetupFunc) spawn_child_setup,
>                              NULL, /* child_setup_user_data */
>                              NULL,
>                              &error)) {
> --
> 2.13.3



-- 
Aleksander
https://aleksander.es


More information about the libmbim-devel mailing list