From c316057f4ec5926b256da8b52b28e689da818b75 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 1 Jun 2020 00:06:51 +0200 Subject: Silence output for initial tracee until it has successfully execed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- sctrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3-70-g09d2