[PATCH] shell: respawn desktop-shell if it dies

Kristian Høgsberg krh at bitplanet.net
Tue Jan 17 08:08:55 PST 2012


On Tue, Jan 17, 2012 at 7:36 AM, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> If the desktop-shell client goes away for any reason, respawn it. To
> avoid harmful looping, limit the respawning to 5 times within 30
> seconds, and then give up.

Great, thanks.  I added a small patch on top to just initialize the
deathstamp at initial
launch time instead of relying on 0 as a special timestamp (which is isn't).

Kristian

> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> ---
>  src/shell.c |   23 +++++++++++++++++++++++
>  1 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/src/shell.c b/src/shell.c
> index 9386d1e..c0d8b8d 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -45,6 +45,9 @@ struct wl_shell {
>                struct weston_process process;
>                struct wl_client *client;
>                struct wl_resource *desktop_shell;
> +
> +               unsigned deathcount;
> +               uint32_t deathstamp;
>        } child;
>
>        bool locked;
> @@ -1264,14 +1267,34 @@ configure(struct weston_shell *base, struct weston_surface *surface,
>        }
>  }
>
> +static int launch_desktop_shell_process(struct wl_shell *shell);
> +
>  static void
>  desktop_shell_sigchld(struct weston_process *process, int status)
>  {
> +       uint32_t time;
>        struct wl_shell *shell =
>                container_of(process, struct wl_shell, child.process);
>
>        shell->child.process.pid = 0;
>        shell->child.client = NULL; /* already destroyed by wayland */
> +
> +       /* if desktop-shell dies more than 5 times in 30 seconds, give up */
> +       time = weston_compositor_get_time();
> +       if (shell->child.deathstamp == 0 ||
> +           time - shell->child.deathstamp > 30000) {
> +               shell->child.deathstamp = time;
> +               shell->child.deathcount = 0;
> +       }
> +
> +       shell->child.deathcount++;
> +       if (shell->child.deathcount > 5) {
> +               fprintf(stderr, "weston-desktop-shell died, giving up.\n");
> +               return;
> +       }
> +
> +       fprintf(stderr, "weston-desktop-shell died, respawning...\n");
> +       launch_desktop_shell_process(shell);
>  }
>
>  static int
> --
> 1.7.3.4
>


More information about the wayland-devel mailing list