strace -f not following child process

Denys Vlasenko dvlasenk at
Tue Jul 9 17:30:47 UTC 2013

On 07/09/2013 09:17 AM, Florian Kelbert wrote:
> On 08.07.2013 10:00, Denys Vlasenko wrote:
>> On 07/05/2013 01:18 PM, Florian Kelbert wrote:
>>> Hi all,
>>> while trying to strace nginx (, using strace -f, I
>>> realized that strace fails to trace a forked child process.
>> Which version of strace and kernel do you have?
> I compiled strace 4.8 from the sources using ./configure && make; using Ubuntu 13.04, kernel 3.8.0-25
>> Can you show the same event with -d option added to strace
>> command line? (the debug output goes to stderr, not -o LOGFILE).
> ./strace -f -d ~/nginx/sbin/nginx
> Process 7428 is born in line 518 and survives the subsequent exit_group() by process 7427, as the output of ps shows:

The log shows that exit_group(0) is indeed called immediately after clone(),
making "strace exited too early to see the child" theory feasible.

Can you test this theory by replacing

	while (nprocs != 0)


	while (1)

in strace.c in function trace()?

The exit from trace loop will then happen when we receive ECHILD.
In my testing it worked.

More information about the Strace-devel mailing list