This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
PATCH: Guard uses of fork
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 9 Mar 2005 20:00:05 -0800
- Subject: PATCH: Guard uses of fork
- Reply-to: mark at codesourcery dot com
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 <mark@codesourcery.com>
* 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)