possible sigchld bug

Markus Friedl markus at openbsd.org
Tue Dec 23 07:18:22 EST 2003


i think this is what openssh's mysignal does...

On Mon, Dec 22, 2003 at 09:10:43PM +0100, Mikulas Patocka wrote:
> > signals are not blocked during execution of handlers?
> 
> On BSD and Linux glibc-2 yes. On SysV or Linux libc-5 no. (on these
> systems, signal handler is restored to default before entering handler
> function).
> 
> You should use sigaction() instead of signal() if you want consistent
> behaviour on all systems.
> 
> Mikulas
> 
> > On Mon, Dec 22, 2003 at 08:26:28PM +0100, Mikulas Patocka wrote:
> > > Hi
> > >
> > > What if you have sysv signals (i.e. signal is restored when handler is
> > > called) and child process exits here? Zombie will be left, because SIGCHLD
> > > is ignored at that point. Shouldn't signal be before waitpid?
> > >
> > > Mikulas
> > >
> > > static void
> > > main_sigchld_handler(int sig)
> > > {
> > >         int save_errno = errno;
> > >         pid_t pid;
> > >         int status;
> > >
> > >         while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
> > >             (pid < 0 && errno == EINTR))
> > >                 ;
> > >
> > > 		<----- HERE
> > >
> > >         signal(SIGCHLD, main_sigchld_handler);
> > >         errno = save_errno;
> > > }
> > >
> > > _______________________________________________
> > > openssh-unix-dev mailing list
> > > openssh-unix-dev at mindrot.org
> > > http://www.mindrot.org/mailman/listinfo/openssh-unix-dev
> >




More information about the openssh-unix-dev mailing list