summaryrefslogtreecommitdiff
path: root/strace.c
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2013-07-10 14:33:05 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2013-07-10 14:36:28 +0200
commitc169d94718e0c3a980dbf352010e615daf2f4332 (patch)
treeae2ae617dd77c10366bb28f3d5ee56e75a62690d /strace.c
parent7c41ce287804f5409400c2b87bf11ebc6f6e1091 (diff)
downloadstrace-c169d94718e0c3a980dbf352010e615daf2f4332.tar.gz
strace-c169d94718e0c3a980dbf352010e615daf2f4332.tar.bz2
strace-c169d94718e0c3a980dbf352010e615daf2f4332.tar.xz
PTRACE_SEIZE can set ptrace options immediately, use this feature
This eliminates some rare bugs, such as post-execve SIGTRAP generation when we attach to a process, and it manages to finish execve'ing before we set TRACEEXEC option to suppress that. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'strace.c')
-rw-r--r--strace.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/strace.c b/strace.c
index 42cfcb9..94706ad 100644
--- a/strace.c
+++ b/strace.c
@@ -335,11 +335,11 @@ ptrace_attach_or_seize(int pid)
{
int r;
if (!use_seize)
- return ptrace(PTRACE_ATTACH, pid, 0, 0);
- r = ptrace(PTRACE_SEIZE, pid, 0, 0);
+ return ptrace(PTRACE_ATTACH, pid, 0L, 0L);
+ r = ptrace(PTRACE_SEIZE, pid, 0L, (unsigned long)ptrace_setoptions);
if (r)
return r;
- r = ptrace(PTRACE_INTERRUPT, pid, 0, 0);
+ r = ptrace(PTRACE_INTERRUPT, pid, 0L, 0L);
return r;
}
#else
@@ -2224,9 +2224,9 @@ trace(void)
return;
}
}
- if (ptrace_setoptions) {
+ if (!use_seize && ptrace_setoptions) {
if (debug_flag)
- fprintf(stderr, "setting opts %x on pid %d\n", ptrace_setoptions, tcp->pid);
+ fprintf(stderr, "setting opts 0x%x on pid %d\n", ptrace_setoptions, tcp->pid);
if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) {
if (errno != ESRCH) {
/* Should never happen, really */