Re: [dev] [PATCH] dwm -- Proper SIGCHLD usage , fix issue with uncollected processes

From: Anselm R Garbe <garbeam_AT_gmail.com>
Date: Thu, 13 Aug 2009 10:13:47 +0100

2009/8/11 Premysl 'Anydot' Hruby <dfenze_AT_gmail.com>:
> This is much cleaner and portable way of using SIGCHLD. It also disallow
> existence of defunct processes, one which are executed for example from
> .Xsession before (on the end) exec /path/../dwm
> ---
>  dwm.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/dwm.c b/dwm.c
> index 873b794..3cb4a8e 100644
> --- a/dwm.c
> +++ b/dwm.c
> @@ -207,7 +207,7 @@ static void setlayout(const Arg *arg);
>  static void setmfact(const Arg *arg);
>  static void setup(void);
>  static void showhide(Client *c);
> -static void sigchld(int signal);
> +static void sigchld(int unused);
>  static void spawn(const Arg *arg);
>  static void tag(const Arg *arg);
>  static void tagmon(const Arg *arg);
> @@ -1428,6 +1428,8 @@ setup(void) {
>        int w;
>        XSetWindowAttributes wa;
>
> +       signal(SIGCHLD, sigchld);
> +
>        /* init screen */
>        screen = DefaultScreen(dpy);
>        root = RootWindow(dpy, screen);
> @@ -1496,13 +1498,13 @@ showhide(Client *c) {
>
>
>  void
> -sigchld(int signal) {
> +sigchld(int unusedl) {
>        while(0 < waitpid(-1, NULL, WNOHANG));
> +       signal(SIGCHLD, sigchld);
>  }
>
>  void
>  spawn(const Arg *arg) {
> -       signal(SIGCHLD, sigchld);
>        if(fork() == 0) {
>                if(dpy)
>                        close(ConnectionNumber(dpy));

I'm fine with this patch, will be applied soon.

--Anselm
Received on Thu Aug 13 2009 - 09:13:47 UTC

This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:18:45 UTC