]> granicus.if.org Git - strace/commitdiff
Forbid using mutually exclusive options -D and -p together
authorWang Chao <wang.chao@cn.fujitsu.com>
Thu, 5 Aug 2010 06:30:11 +0000 (14:30 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 9 Aug 2010 21:28:35 +0000 (21:28 +0000)
If we use -D and -p option together to trace a multi-thread program, in
addition to the main thread, other threads could not be traced even if we
present -f option. Moreover, when executing 'strace -D -p <non-exist pid>',
strace could not terminate normally.

* strace.c (main): Check it.

Signed-off-by: Wang Chao <wang.chao@cn.fujitsu.com>
strace.c

index 21febb3519a88ffb11c97dde8b634e1bd25eff3f..35059483e0f71aa31930cc1b0fe6bb83f8e06556 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -846,6 +846,13 @@ main(int argc, char *argv[])
        if ((optind == argc) == !pflag_seen)
                usage(stderr, 1);
 
+       if (pflag_seen && daemonized_tracer) {
+               fprintf(stderr,
+                       "%s: -D and -p are mutually exclusive options\n",
+                       progname);
+               exit(1);
+       }
+
        if (!followfork)
                followfork = optF;