We help IT Professionals succeed at work.
Get Started

gdb to follow fork'd child processes

pzkhan
pzkhan asked
on
840 Views
Last Modified: 2012-06-21
I am running a server that fork()'s off processes upon new connections in a loop. However, somewhere in the child section of the program there are errors.

I am trying to use gdb to find the problem, but having difficulty having gdb follow the child process. In particular, to do so, I set a break-point before the fork(). Before the fork executes, gdb returns me to the command prompt. I then enter "set fork-follow-mode" to follow a child process through. Once the child terminates, I would expect one of two things:
A) The parent process is executed from where it left off at the break
B) gdb returns me back to the command prompt, but this time to the parent process.

At the least, I would expect gdb to break once again when it reaches the fork() where the break was set.

Instead, the program executes as if the break was not there, and spawns several new child processes. Why is that? Shouldn't the parent stop at the break again?

Please assist.
Comment
Watch Question
Consultant
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE