Red Hat Bugzilla – Bug 187847
Strace -c -o -ff creates empty output files
Last modified: 2007-11-30 17:07:24 EST
Description of problem:
Strace produces empty files when -c -ff and -o are invoked
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. strace -o foo -ff -c some-process-with-children
You will receive an empty summary file for each process
One summary file for the parent and it's children
strace -ff -c some-process-with-children
produces the expected output, but the -o doesn't properly
redirect to file.
Reported to strace developers, with patch:
Created attachment 127260 [details]
Patch for -o -ff -c bug
This is not intended to be an argument against the patch, but the strace man
page pretty clearly indicates that -c and -o are not intended to be used
together. If we go forward with this patch, we should also fix the man page.
I didn't read the man page in that way, it seemed somewhat undefined. The only
link between the 3 options is the appending of pid, as I read it. Maybe my
copy of the man page is outdated?
-c Count time, calls, and errors for each system call
and report a summary on program exit. On Linux,
this attempts to show system time (CPU time spent
running in the kernel) independent of wall clock
-ff If the -o filename option is in effect, each pro-
cesses trace is written to filename.pid where pid is
the numeric process id of each process.
-o filename Write the trace output to the file filename rather
than to stderr. Use filename.pid if -ff is used.
If the argument begins with `|' or with `!' then the
rest of the argument is treated as a command and all
output is piped to it. This is convenient for pip-
ing the debugging output to a program without
affecting the redirections of executed programs.
Either way, I haven't heard from the strace maintainers as yet.
Strictly speaking, I'm neither RH nor upstream strace maintainer.
However, Roland's opinion is not available yet.
I suppose that, as described in strace(1) synopsis, -c is not compatible with
-a, -i, -r, -s, -t, and -x options.
However, I think that -c is compatible with -d, -e, -f, -o, -p, -q, -u, -E and
-F despite of current wording in synopsis.
Regarding to -c -ff -o: unless -c is extended to handle each pid separately,
this combination is not compatible, one should use smth like -c -f -o instead.
That is, both manpage and source code should be corrected: code should reject
incompatible options, and synopsis should be updated.
Ah, I didn't check the summary and you are correct.
I don't think there is a good answer to the -c -ff -o combination, with
-c -ff, it summarizes parent and children so I simply made the action of
-o consistent. It was also easier to code and happened to be the result
set I needed at the time.
-c -f -o and -c -f are consistent and produce a summary of the parent only.
I'm not married to any solution on this, full summary, summary per pid,
declaring the combination invalid or just waiting for the Strace maintainers
to pass judgement.
If I do hear from the Strace maintainers I will update the case with their
I've changed strace upstream to refuse -c and -ff together.
Oh well. :-) Maybe one of these days I'll have the free time to revisit this
and provide a better patch that could support -c -ff/-o in a suitable and
useful manner. It would probably require supporting -c in some other way
depending on whether the user wanted a single summary of parent and children
or parent and each child separately.
Anyway, thanks for taking the time to consider the issue. Now it won't take
anyone by surprise.
Development Management has reviewed and declined this request. You may appeal this decision by reopening this request.