Debugging Child Processes.
Glen Ecklund
glen at astroatc.UUCP
Tue Aug 29 07:47:19 AEST 1989
In article <6840004 at hpcllcm.HP.COM> pratap at hpcllcm.HP.COM (Pratap Subrahmanyam) writes:
>if((pid = fork()) == 0) {
>
>/* How can you step into this area ???? */
>
>}
Simple. Change the == to !=.
You may have problems, however, if pid is used before you are finished
debugging. In typical cases, however, it will not be used except in the
parent, after the child is done.
This will allow you to debug the code up to an exec. If you want to debug
code after an exec, someone else has already posted a solution for that.
If you are using dbx, it is safer to put a breakpoint inside the block,
where your comment is in the above case, and continue. If you "step" or
"next", both processes will have breakpoints in them, and the one you are
not debugging may fail.
If not dbx, this advice may still be relevant, I don't know.
Glen
More information about the Comp.unix.wizards
mailing list