On Fri, Nov 11, 2016 at 12:10:04 -0500, Christos Zoulas wrote:

> Date:         Fri Nov 11 17:10:04 UTC 2016
> 
> Modified Files:
>       src/sys/kern: sys_ptrace_common.c
> 
> Log Message:
> kern/51621: When attaching to a child send it a SIGTRAP not a SIGSTOP like
> Linux and FreeBSD do.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.2 -r1.3 src/sys/kern/sys_ptrace_common.c

Hmm, I'm confused.  The PR says:

- PT_ATTACH seems to work, but waiting for stopped status and signal from the
  child results in getting SIGTRAP, not SIGSTOP like in Linux and FreeBSD.

This revision changes PT_ATTACH case to:

                proc_changeparent(t, p);
-               signo = SIGSTOP;
+               signo = SIGTRAP;
                goto sendsig;

which looks like it's the opposite of what's said in the PR.

FreeBSD from source code inspection (abridged version quoted below)
does indeed send SIGSTOP:

        case PT_ATTACH:
                proc_set_traced(p, true);
                if (p->p_pptr != td->td_proc) {
                        proc_reparent(p, td->td_proc);
                }
                data = SIGSTOP;
                goto sendsig;

>From a very quick look through the code it looks like the intention
(before this commit) is to send SIGSTOP to a process that we attach
to, which is semantically correct, as we want to just stop it as-is
and let the tracer poke at it.

The SIGTRAP comes from the fork path as far as I can tell.

So what's going on here?

-uwe

Reply via email to