]> granicus.if.org Git - strace/commitdiff
Allow -q to be repeated for very quiet output
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 13 May 2013 10:30:55 +0000 (11:30 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 13 May 2013 14:11:31 +0000 (14:11 +0000)
Even with the -q flag specified, tracing output is still mixed
with messages about signals and process exit status, which is
often irrelevant.  Allow the -q option to be repeated to force
the suppression of signals / exit status info too.

* defs.h: Change 'qflag' from 'bool' to 'unsigned int'.
* strace.1: Document ability to repeat '-q' option.
* strace.c: Allow '-q' to be repeated to quieten process
exit status and signal messages.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
defs.h
strace.1
strace.c

diff --git a/defs.h b/defs.h
index 291b8fb279fa7b2221e2fde7bf2fcca01d537b7d..58cdf999b44e5cdebf8c1a523d1e9b9e96feb812 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -539,7 +539,7 @@ typedef enum {
 extern cflag_t cflag;
 extern bool debug_flag;
 extern bool Tflag;
-extern bool qflag;
+extern unsigned int qflag;
 extern bool not_failing_only;
 extern bool show_fd_path;
 /* are we filtering traces based on paths? */
index 00ca03c489d1ac1bbf9e68e40577bfa98bbfcd61..9d628a1854dd96bce7a5b37caf64b9bc9f23d652 100644 (file)
--- a/strace.1
+++ b/strace.1
@@ -267,6 +267,10 @@ Suppress messages about attaching, detaching etc.  This happens
 automatically when output is redirected to a file and the command
 is run directly instead of attaching.
 .TP
+.B \-qq
+If given twice, suppress messages about process exit status and
+signals received.
+.TP
 .B \-r
 Print a relative timestamp upon entry to each system call.  This
 records the time difference between the beginning of successive
index 4cd5835470b3d909d8cfce5fac6cbf1038a24c0b..f6f6e89814234ccb5fe3857b31ce36094722dd45 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -74,7 +74,7 @@ unsigned int xflag = 0;
 bool need_fork_exec_workarounds = 0;
 bool debug_flag = 0;
 bool Tflag = 0;
-bool qflag = 0;
+unsigned int qflag = 0;
 /* Which WSTOPSIG(status) value marks syscall traps? */
 static unsigned int syscall_trap_sig = SIGTRAP;
 static unsigned int tflag = 0;
@@ -1609,7 +1609,7 @@ init(int argc, char *argv[])
                        iflag = 1;
                        break;
                case 'q':
-                       qflag = 1;
+                       qflag++;
                        break;
                case 'r':
                        rflag = 1;
@@ -2112,7 +2112,8 @@ trace(void)
                if (WIFEXITED(status)) {
                        if (pid == strace_child)
                                exit_code = WEXITSTATUS(status);
-                       if (cflag != CFLAG_ONLY_STATS) {
+                       if (cflag != CFLAG_ONLY_STATS &&
+                           qflag < 2) {
                                printleader(tcp);
                                tprintf("+++ exited with %d +++\n", WEXITSTATUS(status));
                                line_ended();
@@ -2221,17 +2222,19 @@ trace(void)
 # define PC_FORMAT_STR ""
 # define PC_FORMAT_ARG /* nothing */
 #endif
-                               printleader(tcp);
-                               if (!stopped) {
-                                       tprintf("--- %s ", signame(sig));
-                                       printsiginfo(&si, verbose(tcp));
-                                       tprintf(PC_FORMAT_STR " ---\n"
-                                               PC_FORMAT_ARG);
-                               } else
-                                       tprintf("--- stopped by %s" PC_FORMAT_STR " ---\n",
-                                               signame(sig)
-                                               PC_FORMAT_ARG);
-                               line_ended();
+                               if (qflag < 2) {
+                                       printleader(tcp);
+                                       if (!stopped) {
+                                               tprintf("--- %s ", signame(sig));
+                                               printsiginfo(&si, verbose(tcp));
+                                               tprintf(PC_FORMAT_STR " ---\n"
+                                                       PC_FORMAT_ARG);
+                                       } else
+                                               tprintf("--- stopped by %s" PC_FORMAT_STR " ---\n",
+                                                       signame(sig)
+                                                       PC_FORMAT_ARG);
+                                       line_ended();
+                               }
                        }
 
                        if (!stopped)