[PATCH] check process death if ptrace() fails
Roland McGrath
roland at redhat.com
Tue Dec 9 09:50:05 UTC 2008
> Changelog:
Format nits:
> 2008-12-08 Denys Vlasenko <dvlasenk at redhat.com>
Blank line here.
> * defs.h (handle_ptrace_err): New function
Use proper punctuation on the sentence. "New function" applies to where
something is defined. defs.h just declares it.
> * strace.c: move process death handling in a static function
> * strace.c, util.c: Call it instead of perror
Use proper capitalization and punctuation. These must cite the affected
functions specifically. Follow the style you see used in the file.
Now, to the patch itself.
Firstly, the cleaner way to organize the source is not handle_ptrace_err,
but to write a wrapper used for all calls to ptrace. That can do the call
and the error checking in one place, making all the callers simpler.
Second, I don't think handle_death is a good idea. That is, don't do a
special-case wait. Let the normal wait logic handle the death report when
it comes. What I think we want is to record the errno in a new tcb field
and go back to the normal loop. Possibly it could immediately print
something new like "<unavailable>", but probably better instead to have a
check for a saved ptrace error in the main loop after the WIFSIGNALED and
WIFEXITED cases. If we get further and there is a saved ptrace error, then
print the "<unavailable>" or perhaps something with the strerror string.
(Then clear the saved error record, since we've reported it.) In the
WIFSIGNALED and WIFEXITED cases, the error is not worth mentioning and the
usual logic will print "<unfinished>" before the death details.
Thanks,
Roland
More information about the Strace-devel
mailing list