summaryrefslogtreecommitdiffstats
path: root/lib/libproc/proc_util.c
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2014-05-04 03:34:32 +0000
committermarkj <markj@FreeBSD.org>2014-05-04 03:34:32 +0000
commitbddfd9feb6bf0e57bbc5d9c020e96bd4168448ad (patch)
treef1394d4a73972700719026b1b857a9c0577ae0e3 /lib/libproc/proc_util.c
parentbaf69d5639fe2290e61dec8cdb426f24b4bef1e5 (diff)
downloadFreeBSD-src-bddfd9feb6bf0e57bbc5d9c020e96bd4168448ad.zip
FreeBSD-src-bddfd9feb6bf0e57bbc5d9c020e96bd4168448ad.tar.gz
If the traced process stops because it received a signal, libproc needs
to ensure that the signal is forwarded when proc_continue() is called. MFC after: 3 weeks
Diffstat (limited to 'lib/libproc/proc_util.c')
-rw-r--r--lib/libproc/proc_util.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/libproc/proc_util.c b/lib/libproc/proc_util.c
index 1c3d522..4d9aa20 100644
--- a/lib/libproc/proc_util.c
+++ b/lib/libproc/proc_util.c
@@ -35,10 +35,9 @@
#include <sys/wait.h>
#include <err.h>
#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
#include <signal.h>
#include <string.h>
+#include <unistd.h>
#include "_libproc.h"
int
@@ -59,11 +58,14 @@ proc_clearflags(struct proc_handle *phdl, int mask)
int
proc_continue(struct proc_handle *phdl)
{
+ int pending = 0;
if (phdl == NULL)
return (-1);
- if (ptrace(PT_CONTINUE, phdl->pid, (caddr_t)(uintptr_t) 1, 0) != 0)
+ if (phdl->status == PS_STOP && WSTOPSIG(phdl->wstat) != SIGTRAP)
+ pending = WSTOPSIG(phdl->wstat);
+ if (ptrace(PT_CONTINUE, phdl->pid, (caddr_t)(uintptr_t)1, pending) != 0)
return (-1);
phdl->status = PS_RUN;
@@ -208,12 +210,16 @@ proc_getlwpstatus(struct proc_handle *phdl)
return (NULL);
siginfo = &lwpinfo.pl_siginfo;
if (lwpinfo.pl_event == PL_EVENT_SIGNAL &&
- (lwpinfo.pl_flags & PL_FLAG_SI) &&
- siginfo->si_signo == SIGTRAP &&
- (siginfo->si_code == TRAP_BRKPT ||
- siginfo->si_code == TRAP_TRACE)) {
- psp->pr_why = PR_FAULTED;
- psp->pr_what = FLTBPT;
+ (lwpinfo.pl_flags & PL_FLAG_SI) != 0) {
+ if (siginfo->si_signo == SIGTRAP &&
+ (siginfo->si_code == TRAP_BRKPT ||
+ siginfo->si_code == TRAP_TRACE)) {
+ psp->pr_why = PR_FAULTED;
+ psp->pr_what = FLTBPT;
+ } else {
+ psp->pr_why = PR_SIGNALLED;
+ psp->pr_what = siginfo->si_signo;
+ }
} else if (lwpinfo.pl_flags & PL_FLAG_SCE) {
psp->pr_why = PR_SYSENTRY;
} else if (lwpinfo.pl_flags & PL_FLAG_SCX) {
OpenPOWER on IntegriCloud