tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: stopfork trick

> That sounds right to me. ps -x should show you a child too.
It doesn't.

Unsing this trivial program:

#include <unistd.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
        printf("pid=%d\n", getpid());
        int pid = fork();
        if (pid < 0) return 1;
        if (pid > 0) puts("parent");
        if (pid == 0) puts("child");
        return 0;

If I set proc.N.stopfork while the program sleeps, it just prints "parent",
i.e. the child doesn't run, and it doesn't show up in ps alx.

> Perhaps add stopexit too to return to the debugger before the parent exits.
If I set both stopfork and stopexit, it behaves as expected, i.e. it prints
"parent", the parent shows up as stopped, the child too, and I can attach gdb
to that child.

If, with both stopfork and stopexit set, I kill -CONT the child, it prints
"child" (as expected). If I then kill -CONT the parent, it exits (as expected).

But, if I kill -CONT the parent first, the stopped child vanishes and doesn't
print "child".

This is on 6.1_RC4/amd64. Is there something broken? (At least gdb seems to be
broken since follow-fork-mode child doesn't work.)

I managed to catch radiusd in the act by setting both stopfork and stopexit
of the shell, then exec'ing radiusd and attach gdb to the child. More on the
results in another message.

Home | Main Index | Thread Index | Old Index