Hi.

There is an old bug in strace - it does not allow specifying both -p and
commandline arguments. Very useful for dealing with things like
pulseaudio. More words there: http://bugs.debian.org/549942

Can you include the attached patch fixes that the bug? It is against
version 4.6.

-- 
Max
From a1c6b9b0cb369ed04e6cd5dbb5c814a57002047e Mon Sep 17 00:00:00 2001
From: Max Kirillov <[email protected]>
Date: Wed, 30 Mar 2011 02:08:54 +0300
Subject: [PATCH 1/5] allow using both -p option and command

* strace.c:
    fix check of options to pass such case
    launch the command if there is an argument for it
    turn on non-interactive status only if there is no -p argument
    print pids to outfile when -p and command both specified
---
 strace.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/strace.c b/strace.c
index 774d172..e54a7a5 100644
--- a/strace.c
+++ b/strace.c
@@ -914,7 +914,7 @@ main(int argc, char *argv[])
                }
        }
 
-       if ((optind == argc) == !pflag_seen)
+       if ((optind == argc) && !pflag_seen)
                usage(stderr, 1);
 
        if (pflag_seen && daemonized_tracer) {
@@ -996,24 +996,16 @@ main(int argc, char *argv[])
 
        if (!outfname || outfname[0] == '|' || outfname[0] == '!')
                setvbuf(outf, buf, _IOLBF, BUFSIZ);
-       if (outfname && optind < argc) {
+       if (outfname && optind < argc && !pflag_seen) {
                interactive = 0;
                qflag = 1;
        }
 
-       /* Valid states here:
-          optind < argc        pflag_seen      outfname        interactive
-          1                    0               0               1
-          0                    1               0               1
-          1                    0               1               0
-          0                    1               1               1
-        */
-
        /* STARTUP_CHILD must be called before the signal handlers get
           installed below as they are inherited into the spawned process.
           Also we do not need to be protected by them as during interruption
           in the STARTUP_CHILD mode we kill the spawned process anyway.  */
-       if (!pflag_seen)
+       if (optind < argc)
                startup_child(&argv[optind]);
 
        sigemptyset(&empty_set);
@@ -2785,7 +2777,7 @@ struct tcb *tcp;
                }
        }
        curcol = 0;
-       if ((followfork == 1 || pflag_seen > 1) && outfname)
+       if ((followfork == 1 || pflag_seen > 1 || (pflag_seen && strace_child)) 
&& outfname)
                tprintf("%-5d ", tcp->pid);
        else if (nprocs > 1 && !outfname)
                tprintf("[pid %5u] ", tcp->pid);
-- 
1.7.1

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to