davidg
davidg

Reputation: 6027

How do I kill strace without killing the process being traced?

I am attempting to debug the startup of an application. I would like to use strace to get a trace of the system calls carried out by the application during its startup, but once the application has started I don't want the performance overhead of strace.

If you run strace normally:

strace -f myprogram

then if you attempt to kill strace, it will take myprogram down with it.

You can attach strace to a running process as follows:

strace -f -p <myprogram pid>

but then it is hard to get a trace of the application's startup.

Is there a way to capture a trace of an application's startup, and then detach strace?

Upvotes: 2

Views: 7699

Answers (1)

davidg
davidg

Reputation: 6027

One method is to use the -D flag of strace, which runs the strace process as a descendant of the process being traced.

For example:

strace -f -D myprogram

will start tracing myprogram. Now running:

killall strace

will kill the strace process, but myprogram will continue to run.

Upvotes: 7

Related Questions