[PATCH] Reset signal handlers in KProcess child

Robert Knight robertknight at gmail.com
Sat Jan 26 12:12:17 GMT 2008


> Hmm... this is not a K/QProcess bug. I guess it's a kdm bug for leaking
> its signal configuration.

I think it is too fragile to rely on every parent in Konsole's process
tree to do the "right thing."

> indeed. i'm just a bit concerned about backwards
> compatibility.

Indeed.  I'd be very surprised if anyone has actually used this
'feature' of signals intentionally - but you never know.

Regards,
Robert.

On 26/01/2008, Oswald Buddenhagen <ossi at kde.org> wrote:
> On Sat, Jan 26, 2008 at 04:22:55AM +0000, Robert Knight wrote:
> > K3Process used to reset signal handler for all signals to SIG_DFL just
> > after forking.
> >
> uh, right. but it did this after calling commSetupDoneC()
> (k3proc setupChildProcess() equivalent), thus leaving the app no chance
> to set up signal ignores on purpose. so: bug there, too. :)
>
> > Konsole ultimately inherited SIGINT from somewhere else, it looks like
> > KDM might be the cause
> >
> whooops ... that must have persisted for > 5 years. :}
>
> > The attached patch causes KProcess to reset its child's signal
> > handlers back to SIG_DFL in setupChildProcess().  Is this the right
> > solution?
> >
> as thiago pointed out, this probably needs to be addressed by tt.
> given that MSDN says "Signal settings are not preserved in spawned
> processes created by calls to _exec or _spawn functions. The signal
> settings are reset to the default in the new process." and QProcess is
> probably expected to behave the same under unix and win, this can be
> considered a bug, indeed. i'm just a bit concerned about backwards
> compatibility.
>
> > +void KProcess::setupChildProcess()
> > +{
> > +#ifndef Q_OS_WIN
> > +     // reset all signal handlers
> > +     struct sigaction action;
> > +     sigemptyset(&action.sa_mask);
> > +     action.sa_handler = SIG_DFL;
> > +     action.sa_flags = 0;
> > +     for (int signal = 1; signal < NSIG; signal++)
> > +             sigaction(signal, &action, 0);
> > +#endif
> > +}
>
> --
> Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
> --
> Confusion, chaos, panic - my work here is done.
>




More information about the kde-core-devel mailing list