Subject: Re: SIGTRAP for traced processes and COMPAT_MACH
To: Jaromir Dolecek <>
From: Emmanuel Dreyfus <>
List: tech-kern
Date: 12/01/2003 14:38:55
Jaromir Dolecek <> wrote:

> > I commented on that topic in another mail: it won't work because sendsig
> > is only reached when the signal is unmasked and catched (ie: a signal
> > handler is installed).
> So unmask it and use dummy handler. What's the problem?

The problem is that this introduce a lot of extra complexity to avoid a
single test in MI codepath.

If we do this, once softsignals are requested, we must set all signals
except the unmaskable ones to catched. This makes
p->p_sigctx->ps_sigcatch permanently out of sync with p->p_sigacts's
catchers. I'm not sure this is really safe. 

With this, we reach darwin_sendsig for any signal except non catchable
signals. There we need to check the signal mask, because no softsignal
exception should be raised if the signal is masked (NB: Mach exceptions
raised from trapsignal do not honour the signal mask, but we won't see
them in darwin_sendsig)

If the signal is masked, we should just return. 

If the signal should be turned into a Mach exception, no problem, do it
and just return

In theses two cases, there might be a lot of problems because kpsignal2
and kpsendsig thought the signal was to be sent and did a lot of
operation to prepare it. I don't know that code enough to evaluate if
this is okay or not. 

Last point, if there is no exception port registered, if the exception
port turned dead (nobody listen on the recive end), then we have to send
the signal. But as we always get there regardless if there is a signal
handler or not, we must check for a shadow catch mask. 

This shadow catch mask must be modified instead of the real one by
sigaction when a Darwin process try to install a signal handler.

This is a lot of code, with various place wheres I suspect there could
be a can of worms awaiting to be open. And this is just to avoid the
following test at the begining of kpsignal2, so I'm not sure this is The
Right Way.

         * Allow emulation-specific signal filtering
        if ((p->p_emul->e_sigfilter != NULL) &&
            ((*p->p_emul->e_sigfilter)(l, ksi) == 0))

(I propose e_sigfilter instead of e_checksignal, it reminds better of
what this is doing).

Emmanuel Dreyfus
Il y a 10 sortes de personnes dans le monde: ceux qui comprennent 
le binaire et ceux qui ne le comprennent pas.