aboutsummaryrefslogtreecommitdiffstats
path: root/sctrace.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-06-01 00:06:51 +0200
committerMattias Andrée <maandree@kth.se>2020-06-01 00:06:51 +0200
commitc316057f4ec5926b256da8b52b28e689da818b75 (patch)
tree9d00f7fe7149065fbc8a02df8c5d1d327b01fbd1 /sctrace.c
parentThings work as expected again (diff)
downloadsctrace-c316057f4ec5926b256da8b52b28e689da818b75.tar.gz
sctrace-c316057f4ec5926b256da8b52b28e689da818b75.tar.bz2
sctrace-c316057f4ec5926b256da8b52b28e689da818b75.tar.xz
Silence output for initial tracee until it has successfully execed
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'sctrace.c')
-rw-r--r--sctrace.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sctrace.c b/sctrace.c
index f86d830..de16ddd 100644
--- a/sctrace.c
+++ b/sctrace.c
@@ -63,6 +63,8 @@ handle_syscall(struct process *proc)
/* Print system call result */
print_systemcall_exit(proc);
+ proc->silent_until_execed -= (proc->silent_until_execed == 1);
+
/* Make process continue and stop at next syscall */
if (ptrace(PTRACE_SYSCALL, proc->pid, NULL, 0))
eprintf("ptrace PTRACE_SYSCALL %ju NULL 0:", (uintmax_t)proc->pid);
@@ -71,6 +73,8 @@ handle_syscall(struct process *proc)
break;
case Exec:
+ proc->silent_until_execed -= (proc->silent_until_execed == 2);
+ /* fall through */
case VforkParent:
if (ptrace(PTRACE_SYSCALL, proc->pid, NULL, 0))
eprintf("ptrace PTRACE_SYSCALL %ju NULL 0:", (uintmax_t)proc->pid);
@@ -219,7 +223,7 @@ main(int argc, char **argv)
outfp = outfile ? xfopen(outfile, "wb") : stderr;
setup_trace_output(outfp, multiprocess);
init_process_list();
- add_process(orig_pid, trace_options);
+ add_process(orig_pid, trace_options)->silent_until_execed = 2;
for (;;) {
pid = waitpid(-1, &status, __WALL | WCONTINUED);