summaryrefslogtreecommitdiff
path: root/strace.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2013-05-13 11:30:55 +0100
committerDmitry V. Levin <ldv@altlinux.org>2013-05-13 14:11:31 +0000
commit01997cf32d4492b9898283ced45e8a4a6fd161b8 (patch)
treef2ed4dc0c0519a09ad975fec55b95ae50e6791e6 /strace.c
parent8190912d2e97c9d18de65dc8a6fbd93750642bd3 (diff)
downloadstrace-01997cf32d4492b9898283ced45e8a4a6fd161b8.tar.gz
strace-01997cf32d4492b9898283ced45e8a4a6fd161b8.tar.bz2
strace-01997cf32d4492b9898283ced45e8a4a6fd161b8.tar.xz
Allow -q to be repeated for very quiet output
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>
Diffstat (limited to 'strace.c')
-rw-r--r--strace.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/strace.c b/strace.c
index 4cd5835..f6f6e89 100644
--- 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)