News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to debug the "fork()" program?

Started by gonboy, August 13, 2008, 03:03:15 AM

Previous topic - Next topic

gonboy


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

The fork method is very problematic. Why can't it work fine like any other compiler?????

oBFusCATed

Quote from: Belette13 on November 30, 2010, 09:44:01 PM
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!]

eranif

Quote from: gonboy 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?



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

Eran