From bb34801dd63e0f02d1c49ad0bb0b1a874f39da8e Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Sun, 29 Oct 2006 17:25:15 +0000 Subject: [PATCH] Redefine `UX_vfork' to be `fork' on OS X, because setsid and others are not allowed in vforked processes. Always check the value of setsid, since it should work on OS X now that we use fork there instead of vfork. --- v7/src/microcode/ux.h | 9 ++++++++- v7/src/microcode/uxproc.c | 6 +----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 568b091fa..2732f9f49 100644 --- a/v7/src/microcode/ux.h +++ b/v7/src/microcode/ux.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ux.h,v 1.79 2006/09/16 11:19:09 gjr Exp $ +$Id: ux.h,v 1.80 2006/10/29 17:25:15 riastradh Exp $ Copyright 1990,1991,1992,1993,1994,1995 Massachusetts Institute of Technology Copyright 1996,1997,1998,1999,2000,2003 Massachusetts Institute of Technology @@ -736,6 +736,13 @@ extern int EXFUN (UX_terminal_set_state, (int, Ttty_state *)); extern int EXFUN (UX_tcsetpgrp, (int, pid_t)); # define EMULATE_TCSETPGRP #endif + +/* In Darwin, setsid doesn't work in vforked processes, + so force the use of fork instead. */ +#ifdef __APPLE__ +# undef UX_vfork +# define UX_vfork fork +#endif #ifdef HAVE_SIGACTION diff --git a/v7/src/microcode/uxproc.c b/v7/src/microcode/uxproc.c index a814351c8..e4e7fbc15 100644 --- a/v7/src/microcode/uxproc.c +++ b/v7/src/microcode/uxproc.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxproc.c,v 1.30 2006/09/16 11:19:09 gjr Exp $ +$Id: uxproc.c,v 1.31 2006/10/29 17:25:15 riastradh Exp $ Copyright (c) 1990-2001, 2006 Massachusetts Institute of Technology @@ -335,12 +335,8 @@ DEFUN (OS_make_subprocess, { /* If the control terminal is not inherited, force the child into a different session. */ -#ifdef __APPLE__ - UX_setsid (); -#else if ((UX_setsid ()) < 0) goto kill_child; -#endif /* If the control terminal is explicit, open the given device now so it becomes the control terminal. */ if (ctty_type == process_ctty_type_explicit) -- 2.25.1