bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26397: [PATCH] Use vfork if possible on Darwin (bug#26397)


From: Alan Third
Subject: bug#26397: [PATCH] Use vfork if possible on Darwin (bug#26397)
Date: Sun, 9 Apr 2017 20:18:49 +0100
User-agent: Mutt/1.7.2 (2016-11-26)

src/conf_post.h: Remove defines forcing use of fork.
src/process.c (create_process): Use fork if pty_flag is set, otherwise
vfork.
---
 src/conf_post.h | 6 ------
 src/process.c   | 9 +++++++++
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/conf_post.h b/src/conf_post.h
index 30c948e39a..95ebd5511c 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -99,12 +99,6 @@ typedef bool bool_bf;
 #define realloc unexec_realloc
 #define free unexec_free
 #endif
-/* The following solves the problem that Emacs hangs when evaluating
-   (make-comint "test0" "/nodir/nofile" nil "") when /nodir/nofile
-   does not exist.  Also, setsid is not allowed in the vfork child's
-   context as of Darwin 9/Mac OS X 10.5.  */
-#undef HAVE_WORKING_VFORK
-#define vfork fork
 #endif  /* DARWIN_OS */
 
 /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use
diff --git a/src/process.c b/src/process.c
index 2f2e5c1b25..47a85f1c95 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2049,7 +2049,16 @@ create_process (Lisp_Object process, char **new_argv, 
Lisp_Object current_dir)
   int volatile forkerr_volatile = forkerr;
   struct Lisp_Process *p_volatile = p;
 
+#ifdef DARWIN_OS
+  /* Darwin doesn't let us run setsid after a vfork, so use fork when
+     necessary. */
+  if (pty_flag)
+    pid = fork ();
+  else
+    pid = vfork ();
+#else
   pid = vfork ();
+#endif
 
   current_dir = current_dir_volatile;
   lisp_pty_name = lisp_pty_name_volatile;
-- 

Here’s a tidied up version. If nobody complains I’ll push it in a few
days.

Thanks for your help.

-- 
Alan Third





reply via email to

[Prev in Thread] Current Thread [Next in Thread]