From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18210 invoked by alias); 10 Mar 2005 04:00:12 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 18126 invoked from network); 10 Mar 2005 04:00:06 -0000 Received: from unknown (HELO sirius.codesourcery.com) (65.74.133.4) by sourceware.org with SMTP; 10 Mar 2005 04:00:06 -0000 Received: from sirius.codesourcery.com (localhost.localdomain [127.0.0.1]) by sirius.codesourcery.com (8.12.8/8.12.5) with ESMTP id j2A406YE021373 for ; Wed, 9 Mar 2005 20:00:06 -0800 Received: (from mitchell@localhost) by sirius.codesourcery.com (8.12.8/8.12.8/Submit) id j2A4055p021369; Wed, 9 Mar 2005 20:00:05 -0800 Date: Thu, 10 Mar 2005 04:00:00 -0000 Message-Id: <200503100400.j2A4055p021369@sirius.codesourcery.com> From: Mark Mitchell To: gdb-patches@sources.redhat.com Subject: PATCH: Guard uses of fork Reply-to: mark@codesourcery.com X-SW-Source: 2005-03/txt/msg00167.txt.bz2 This patch uses the HAVE_WORKING_FORK and HAVE_WORKING_VFORK macros appropriately to guard calls to these functions. (These macros are already being defined by autoconf; we just need to use them.) I'm checking HAVE_WORKING_FORK, even in the case of the call to vfork in cli-cmds.c, because autoconf will "#define vfork fork" if there's no vfork, but there is fork. I left the CANT_FORK define in place because that's defined by defs.h in the case __MSDOS__, and Dan says that configure isn't run in that case. I think it could safely be removed (as surely, on __MSDOS__, nothing will define HAVE_WORKING_[V]FORK, but I don't have a way of testing that. I'm happy to make that change as well, if people would like. OK to apply? -- Mark Mitchell CodeSourcery, LLC mark@codesourcery.com 2005-03-09 Mark Mitchell * utils.c (internal_vproblem): Guard call to fork with HAVE_FORK. * cli/cli-cmds.c (shell_escape): Guard call to vfork with HAVE_WORKING_VFORK and HAVE_WORKING_FORK. Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.157 diff -c -5 -p -r1.157 utils.c *** utils.c 24 Feb 2005 13:51:35 -0000 1.157 --- utils.c 10 Mar 2005 02:08:35 -0000 *************** further debugging may prove unreliable." *** 787,798 **** --- 787,800 ---- } else { if (dump_core_p) { + #ifdef HAVE_WORKING_FORK if (fork () == 0) abort (); /* NOTE: GDB has only three calls to abort(). */ + #endif } } dejavu = 0; } Index: cli/cli-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v retrieving revision 1.57 diff -c -5 -p -r1.57 cli-cmds.c *** cli/cli-cmds.c 24 Feb 2005 13:51:36 -0000 1.57 --- cli/cli-cmds.c 10 Mar 2005 02:08:35 -0000 *************** echo_command (char *text, int from_tty) *** 482,492 **** } static void shell_escape (char *arg, int from_tty) { ! #ifdef CANT_FORK /* If ARG is NULL, they want an inferior shell, but `system' just reports if the shell is available when passed a NULL arg. */ int rc = system (arg ? arg : ""); if (!arg) --- 482,493 ---- } static void shell_escape (char *arg, int from_tty) { ! #if defined(CANT_FORK) || \ ! (!defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK)) /* If ARG is NULL, they want an inferior shell, but `system' just reports if the shell is available when passed a NULL arg. */ int rc = system (arg ? arg : ""); if (!arg)