Bug 265941

Summary: ltrace can't follow the child process.
Product: Red Hat Enterprise Linux 5 Reporter: Gui Jianfeng <guijianfeng>
Component: ltraceAssignee: Petr Machata <pmachata>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 5.0CC: ebachalo, jbastian, mnewsome, mnowak, syeghiay, tao
Target Milestone: beta   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-18 15:00:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
This is a patch to fix this issue.
none
Fix for RHEL-5 none

Description Gui Jianfeng 2007-08-30 00:49:30 UTC
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):
RHEL5

How reproducible:
100%


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");
                sleep(1);
        } else if(pid > 0) {
                printf("This is parent\n");
        } else {
                exit(1);
        }
        exit(0);
}

Comment 1 Gui Jianfeng 2007-08-30 00:49:30 UTC
Created attachment 180181 [details]
This is a patch to fix this issue.

Comment 2 Gui Jianfeng 2008-02-02 02:54:30 UTC
This bug still exists in RHEL5.1.

Comment 17 Petr Machata 2009-02-24 17:49:08 UTC
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 15:00:46 UTC
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.

http://rhn.redhat.com/errata/RHBA-2009-0380.html