Re: strace only one child process



tmp123 wrote:
Hello,

Thanks for your time.

In the sytem I'm working, one server process creates one child process
for each client request. I like to strace one of these child process.
strace without specific options only traces the parent, and with the
"-f" option traces all childs, overloading the system.

Knows someone any trick to trace only one (or a few ones) childs.

I wonder whether the ptrace request PTRACE_TRACEME can be used to wait
for a tracing program that is not the parent of a process, but just any
random process doing a PTRACE_ATTACH.

If that's the case you could implement a little hack whereby one of the
children simply arranges to be traced, right after it is forked. That
is to say, it forks off an strace job, passing its own pid in the
command line, and then calls ptrace with PTRACE_TRACEME to wait for
strace to attach.

Such a thing, if possible, could be abstracted into a debugging
function:

void traceme(const char *cmd_fmt, ...);

Then in any process you want, just call

traceme("strace -o trace_file -p %d", (int) getpid());

and after this point you are sure that everything is traced, provided
that strace was launched successfully. Just a hypothetical idea.

Or you could get the strace code, and hack it into having the filtering
functionality that you want.

.



Relevant Pages

  • Re: strace one child process
    ... I like to "strace" one of these child process. ... "-f" option traces all childs, ...
    (comp.os.linux.misc)
  • Re: strace one child process
    ... I like to "strace" one of these child process. ... "-f" option traces all childs, overloading the system. ...
    (comp.os.linux.misc)
  • Re: strace one child process
    ... I like to "strace" one of these child process. ... strace without specific options only traces the parent, ... "-f" option traces all childs, ...
    (comp.os.linux.misc)
  • Re: strace one child process
    ... I like to "strace" one of these child process. ... "-f" option traces all childs, overloading the system. ...
    (comp.os.linux.misc)
  • Re: ktrace as a replacement for strace
    ... > I'm looking for a replacement for the strace program I used to use on ... forks the child process. ... zsh: 62219 suspended strace date ... Take a look at the truss command in the base system, ...
    (freebsd-questions)