From: Nate Sammons Date: Mon, 29 Mar 1999 22:57:54 +0000 (+0000) Subject: Add capability for Linux to change a vfork call into plain fork, which X-Git-Tag: v4.5.18~1233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ccd8f216267cea2f56567b8a44929475105b8298;p=strace Add capability for Linux to change a vfork call into plain fork, which can be followed. (Requires a kernel patch for now.) Also document it. --- diff --git a/process.c b/process.c index 5fc7744f..5ecaa16c 100644 --- a/process.c +++ b/process.c @@ -285,13 +285,24 @@ struct tcb *tcp; { struct tcb *tcpchild; int pid; - int vforking = 0; + int dont_follow = 0; #ifdef SYS_vfork - vforking = (tcp->scno == SYS_vfork); + if (tcp->scno == SYS_vfork) { +#if defined(I386) && defined(LINUX) + /* Attempt to make vfork into fork, which we can follow. */ + if (!followvfork || + ptrace(PTRACE_POKEUSR, tcp->pid, + (void *)(ORIG_EAX * 4), SYS_fork) < 0) + dont_follow = 1; + +#else + dont_follow = 1; +#endif + } #endif if (entering(tcp)) { - if (!followfork || vforking) + if (!followfork || dont_follow) return 0; if (nprocs == MAX_PROCS) { tcp->flags &= ~TCB_FOLLOWFORK; diff --git a/strace.1 b/strace.1 index 5f045f96..56e02da3 100644 --- a/strace.1 +++ b/strace.1 @@ -236,9 +236,10 @@ option is in effect, each processes trace is written to where pid is the numeric process id of each process. .TP .B \-F -On SunOS 4.x, this option has the effect of attempting to follow -vforks by performing some dynamic linking trickery. Otherwise, -vforks will not be followed even if +Attempt to follow vforks. (On SunOS 4.x, this is accomplished with +some dynamic linking trickery. On Linux, it requires some kernel +functionality not yet in the standard kernel.) Otherwise, vforks will +not be followed even if .B \-f has been given. .TP