On (12/08/09 17:24), Jukka Salmi wrote:
> Date: Wed, 12 Aug 2009 17:24:24 +0200
> From: Jukka Salmi <j+dwm_AT_2009.salmi.ch>
> To: dev_AT_suckless.org
> Subject: Re: [dev] [PATCH] dwm -- Proper SIGCHLD usage , fix issue with
> uncollected processes
> List-Id: dev mail list <dev.suckless.org>
> User-Agent: Mutt/1.5.20 (2009-06-20)
>
> 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?
>
According to POSIX, if the signal is blocked after sighandler or not is
undefined. In case of Linux and GLibc it depends on version of Glibc and
-std etc... (read man 2 signal, section Portability).
-Ph
-- Premysl "Anydot" Hruby, http://www.redrum.cz/ - I'm a signature virus. Please add me to your signature and help me spread!Received on Wed Aug 12 2009 - 15:39:26 UTC
This archive was generated by hypermail 2.2.0 : Sun Aug 16 2009 - 14:18:42 UTC