From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10792 invoked by alias); 7 Aug 2006 20:21:07 -0000 Received: (qmail 10784 invoked by uid 22791); 7 Aug 2006 20:21:06 -0000 X-Spam-Check-By: sourceware.org Received: from www.nabble.com (HELO talk.nabble.com) (72.21.53.35) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 07 Aug 2006 20:21:04 +0000 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1GABaw-00018A-Pf for gdb@sources.redhat.com; Mon, 07 Aug 2006 13:21:02 -0700 Message-ID: <5693501.post@talk.nabble.com> Date: Mon, 07 Aug 2006 20:21:00 -0000 From: "Richard (sent by Nabble.com)" Reply-To: Richard To: gdb@sources.redhat.com Subject: fork debugging : back to parent. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-Sender: lists@nabble.com X-Nabble-From: Richard X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-08/txt/msg00040.txt.bz2 Below is the code from "Advanced programming in the Unix environment". if I set follow-fork to child, I can step ok to the exclp line. But how do I get back to debugging the parent process? Is it possible? I tried setting follow-fork back to "parent" and then "c"ontinuing but no joy. or do I have to specifically save process ids and reattach to the parent process? ======= #include "apue.h" #include int main(void) { char buf[MAXLINE]; /* from apue.h */ pid_t pid; int status; printf("%% "); /* print prompt (printf requires %% to print %) */ while (fgets(buf, MAXLINE, stdin) != NULL) { if (buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = 0; /* replace newline with null */ if ((pid = fork()) < 0) { err_sys("fork error"); } else if (pid == 0) { /* child */ execlp(buf, buf, (char *)0); err_ret("couldn't execute: %s", buf); exit(127); } /* parent */ if ((pid = waitpid(pid, &status, 0)) < 0) err_sys("waitpid error"); printf("%% "); } exit(0); } -- View this message in context: http://www.nabble.com/fork-debugging-%3A-back-to-parent.-tf2067795.html#a5693501 Sent from the gdb - General forum at Nabble.com.