PTRACE_GETSIGINFO on job control stops and process exits (WEXITED /WSIGNALED) should error out.

What does PTRACE_GETSIGINFO return on various ptrace-generatedSIGTRAPs and SIGSTOPs?Error? If not, what value is returned in siginfo->si_code?

We have the following kinds of SIGTRAPs:

* real SIGTRAP signal sent by breakpoint instruction* real SIGTRAP signal sent by other process* entering syscall (after PTRACE_SYSCALL)* exiting syscall (after PTRACE_SYSCALL)* after single step (after PTRACE_SINGLESTEP)* after execve (if PTRACE_O_TRACEEXEC opt is not on)* after execve (if PTRACE_O_TRACEEXEC opt is on)* in parent after fork (if PTRACE_O_TRACEFORK opt is on)* in parent after vfork (if PTRACE_O_TRACEVFORK opt is on)* in parent after clone (if PTRACE_O_TRACECLONE opt is on)* in child after vfork (if PTRACE_O_TRACEVFORKDONE opt is on)* before exit (if PTRACE_O_TRACEEXIT opt is on)

Currently strace has to keep precise track on the alternating sequenceof syscall enter/syscall exit stops. Which gets even trickierwith extra magic SIGTRAP thrown in by execve and such.There were (and I suspect will be) hard to debug bugs when stracewas getting out-of sync and printing garbage.

Defining the PTRACE_GETSIGINFO's si_code so that each of these stopscan be easily distinguished would be useful. I propose using valuesof SI_KERNEL + 1, SI_KERNEL + 2 etc, suitably #defined of course.

We also have magic SIGSTOPs (magic in a sense they aren'treal signals sent by other processes):* at PTRACE_ATTACH* in child (if PTRACE_O_TRACE[V]FORK or PTRACE_O_TRACECLONE opt is on)

For example, flagging PTRACE_ATTACH SIGSTOP so that it can beuniquely identified would solve some problems gdb is having with it.