Premysl 'Anydot' Hruby --> dev (2009-08-11 23:43:58 +0200):
> 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));
Seems fine, but -- assuming POSIX.1 reliable signals -- you don't need
to reestablish the handler before returning from it. Or should systems
with the old semantics really be supported by dwm?
Regards, Jukka
-- This email fills a much-needed gap in the archives.Received on Wed Aug 12 2009 - 15:24:24 UTC
This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:18:42 UTC