Bug 265941 - ltrace can't follow the child process.
ltrace can't follow the child process.
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: ltrace (Show other bugs)
ia64 Linux
medium Severity high
: beta
: ---
Assigned To: Petr Machata
Depends On:
  Show dependency treegraph
Reported: 2007-08-29 20:49 EDT by Gui Jianfeng
Modified: 2015-05-04 21:33 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-03-18 11:00:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
This is a patch to fix this issue. (863 bytes, patch)
2007-08-29 20:49 EDT, Gui Jianfeng
no flags Details | Diff
Fix for RHEL-5 (1.01 KB, patch)
2009-02-24 12:49 EST, Petr Machata
no flags Details | Diff

  None (edit)
Description Gui Jianfeng 2007-08-29 20:49:30 EDT
Description of problem:
if use  "ltrace -f" to trace a process which could create a new process, 
ltrace can't trace the new created process.
I have made a patch to fix this issue.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
#ltrace -f ./child
the child will create a new process by fork()
Actual results:
ltrace fails to trace the new created process, it reported as follow:
fork(Cannot attach to pid 18609: Operation not permitted
signal from wrong pid 18609 ?!?

Expected results:
ltrace shall trace the new created process.

Additional info:
traced program child.c is as follow:
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>

int main()
        pid_t pid;
        pid = fork();
        if(pid == 0) {
                printf("This is child\n");
        } else if(pid > 0) {
                printf("This is parent\n");
        } else {
Comment 1 Gui Jianfeng 2007-08-29 20:49:30 EDT
Created attachment 180181 [details]
This is a patch to fix this issue.
Comment 2 Gui Jianfeng 2008-02-01 21:54:30 EST
This bug still exists in RHEL5.1.
Comment 17 Petr Machata 2009-02-24 12:49:08 EST
Created attachment 333069 [details]
Fix for RHEL-5

This patch uses the same approach to solve the problem as strace does, namely that it assumes that unknown pid that occurs in follow-fork mode is a new child, and starts tracing it.
Comment 21 errata-xmlrpc 2009-03-18 11:00:46 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


Note You need to log in before you can comment on or make changes to this bug.