Author Topic: How to debug the "fork()" program?  (Read 8367 times)

Offline gonboy

  • Multiple posting newcomer
  • *
  • Posts: 29
How to debug the "fork()" program?
« on: August 13, 2008, 03:03:15 am »

1 -    You can get  the return value of fork(),so you can debug it. eg pid = 0, in the children process, pid >0 ,in the father process.

        But if I want to debug the father and children process at the same time ,how to do?

2 -    How do you know which process will be run ? why?


Belette13

  • Guest
Re: How to debug the "fork()" program?
« Reply #1 on: November 30, 2010, 09:44:01 pm »
The fork method is very problematic. Why can't it work fine like any other compiler?????

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to debug the "fork()" program?
« Reply #2 on: December 01, 2010, 01:15:48 am »
The fork method is very problematic. Why can't it work fine like any other compiler?????
Compiler or debugger?

As far as I know forks works perfectly using gcc as compiler.
And here is some info related to the debugger: http://sourceware.org/gdb/onlinedocs/gdb/Forks.html

I'm not sure if gdb supports debugging both parent and child, I've not read the above page  :lol: :P
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline eranif

  • Regular
  • ***
  • Posts: 256
Re: How to debug the "fork()" program?
« Reply #3 on: December 01, 2010, 06:57:41 am »

1 -    You can get  the return value of fork(),so you can debug it. eg pid = 0, in the children process, pid >0 ,in the father process.

        But if I want to debug the father and children process at the same time ,how to do?

2 -    How do you know which process will be run ? why?



Here, let me google that for you:
http://tinyurl.com/2fcpot8

Eran