🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49722

gdb and fork()

#49722
From: Jerry Bakin
Date: Mon, 03 Jan 1994 08:26
27 lines
1235 bytes
What aid can gdb give me when I encounter a fork?

Can I get gdb to automatically attach to the new process?

  pid = fork();
  if (pid == 0) {
     <childs_journeys>
  }
  else if (pid > 0) {
     <parental_trip>
  }
  else abort();

If I set a breakpoint in the middle of childs_journeys will it ever get
there?

It doesn't seem to.  I hit breakpoints in the middle of parental_trip,
but never in childs_journeys.  If I use 'ps', I find defunct, Zombies,
hardly what I want my children to be.

What can I do, all the interesting stuff in this program is in the
children!  (I know living life through my children is never good for
anyone.) 

Thanks,

Jerry.
Technical Details
Message-ID: <JBAKIN.94Jan3002643@towada-2.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!news.intercon.com!uhog.mit.edu!uw-beaver!cornell!rochester!rocksanne!spectrum!jbakin

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,cd99404f39289b05,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1994-01-03 02:19:02 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!news.intercon.com!uhog.mit.edu!uw-beaver!cornell!rochester!rocksanne!spectrum!jbakin
From: jbakin@towada-2.com (Jerry Bakin)
Subject: gdb and fork()
Message-ID: <JBAKIN.94Jan3002643@towada-2.com>
Sender: news@spectrum.xerox.com
Organization: Xerox
Date: Mon, 3 Jan 1994 08:26:43 GMT
Lines: 28