Closed bhaible closed 5 years ago
strace has an option for this case, try
$ strace -I 4 -o /tmp/log ./a.out
Yes, with -I 4
it works as expected.
Why is -I 4
not the default?
Traditional defaults are often OK, but sometimes they are not, so -I
option was introduced in strace 4.7 to control strace interactiveness.
There must be an inherent bug or a massive shift in use patterns to change a traditional default behavior like this.
-I
option is documented in strace manual page. If you don't find the documentation appropriate enough, patches are always welcome.
Answering my own question: Why is -I 4
not the default?
I tried to use it for a while, and for processes that being put into the background, it operates worse than the default mode.
Try -D -I4
.
Yes, -D -I4
produces a good behaviour regarding processes that catch SIGTSTP and get put into the background/foreground. Why is this not the default?
> There must be an inherent bug or a massive shift in use patterns to change a traditional default behavior like this. Sending a process SIGSTOP instead of SIGTSTP is an inherent bug.
Thanks for your help! Using a well-working strace is much more comfortable than debugging through log statements.
Thanks, I'm also inclined to think -I4
would be better default for -D
than the current one.
It's less obvious with making -D
the default: the current strace behavior to wait for all processes including those created for piped output (-o
option) is useful only if -D
option is not used.
When a program is run in a terminal, and the user presses Ctrl-Z (the SUSP key), the program receives a SIGTSTP signal. The default action is to stop the program.
When a program is, however, run under strace in a terminal, and the user presses Ctrl-Z, the program does not receive a SIGTSTP signal. Most probably it receives a SIGSTOP signal (for which no signal handlers can be installed).
How to reproduce: I'm using strace 4.11 on Ubuntu 16.04. Here is a program sigtstp-example.c.
You can see that, when run under strace:
I'm debugging a program that makes use of a SIGTSTP handler, and it took me a real while to understand why it is malfunctioning under strace.