diff options
author | Mattias Andrée <maandree@kth.se> | 2020-05-30 21:58:20 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-05-30 21:58:20 +0200 |
commit | 1a92b6b3b88cd2b8a25cd0a90f9c98196fccca6c (patch) | |
tree | 251e9c6d35df8072c03f6f0ddbcec11e8a8afbdf /sctrace.c | |
parent | m + add support for tracing vfork children (diff) | |
download | sctrace-1a92b6b3b88cd2b8a25cd0a90f9c98196fccca6c.tar.gz sctrace-1a92b6b3b88cd2b8a25cd0a90f9c98196fccca6c.tar.bz2 sctrace-1a92b6b3b88cd2b8a25cd0a90f9c98196fccca6c.tar.xz |
Add -0 flag
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'sctrace.c')
-rw-r--r-- | sctrace.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -8,7 +8,7 @@ char *argv0; static void usage(void) { - fprintf(stderr, "usage: %s [-o trace-output-file] [-f] command ...\n", argv0); + fprintf(stderr, "usage: %s [-o trace-output-file] [-f] (command | -0 command argv0) [argument] ...\n", argv0); exit(1); } @@ -91,16 +91,18 @@ main(int argc, char **argv) char *outfile = NULL; FILE *outfp = stderr; const char *num = NULL; - int status, exit_value = 0, trace_event; + int status, exit_value = 0, trace_event, with_argv0 = 0; unsigned long int trace_options = PTRACE_O_EXITKILL | PTRACE_O_TRACESYSGOOD; struct process *proc, *proc2; unsigned long int event; - /* TODO add support for exec */ + /* TODO add support for exec after vfork */ /* TODO add option to trace threads (-t) */ /* TODO add option to trace signals (-s) */ - /* TODO add option to specify argv[0] */ ARGBEGIN { + case '0': + with_argv0 = 1; + break; case 'o': if (outfile) usage(); @@ -130,7 +132,7 @@ main(int argc, char **argv) return 1; } /* exec will block until parent attaches */ - execvp(*argv, argv); + execvp(*argv, &argv[with_argv0]); eprintf("execvp %s:", *argv); default: orig_pid = pid; |