diff options
| author | Alan Third | 2017-04-09 20:10:33 +0100 |
|---|---|---|
| committer | Alan Third | 2017-04-18 11:42:30 +0100 |
| commit | a13eaddce2ddbe3ba0b7f4c81715bc0fcdba99f6 (patch) | |
| tree | 5bf3f0b8fbd2187bb5e08261f29811ea269d4a33 /src | |
| parent | 4ad6be65f68a5c875ecbaa9e66d8ced28f43670a (diff) | |
| download | emacs-a13eaddce2ddbe3ba0b7f4c81715bc0fcdba99f6.tar.gz emacs-a13eaddce2ddbe3ba0b7f4c81715bc0fcdba99f6.zip | |
Use vfork if possible on Darwin (bug#26397)
Co-authored-by: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
* src/conf_post.h (HAVE_WORKING_VFORK): Don't undef.
(vfork): Don't define.
* src/process.c (create_process) [DARWIN_OS]: Use fork if pty_flag is
set, otherwise vfork.
* src/callproc.c (call_process) [DARWIN_OS]: Use TIOCNOTTY to detach
the controlling terminal instead of setsid.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 13 | ||||
| -rw-r--r-- | src/conf_post.h | 6 | ||||
| -rw-r--r-- | src/process.c | 9 |
3 files changed, 22 insertions, 6 deletions
diff --git a/src/callproc.c b/src/callproc.c index 05048576ce9..792556c8e02 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -52,6 +52,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 52 | #include "syswait.h" | 52 | #include "syswait.h" |
| 53 | #include "blockinput.h" | 53 | #include "blockinput.h" |
| 54 | #include "frame.h" | 54 | #include "frame.h" |
| 55 | #include "systty.h" | ||
| 56 | #include "keyboard.h" | ||
| 55 | 57 | ||
| 56 | #ifdef MSDOS | 58 | #ifdef MSDOS |
| 57 | #include "msdos.h" | 59 | #include "msdos.h" |
| @@ -626,7 +628,18 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, | |||
| 626 | { | 628 | { |
| 627 | unblock_child_signal (&oldset); | 629 | unblock_child_signal (&oldset); |
| 628 | 630 | ||
| 631 | #ifdef DARWIN_OS | ||
| 632 | /* Darwin doesn't let us run setsid after a vfork, so use | ||
| 633 | TIOCNOTTY when necessary. */ | ||
| 634 | int j = emacs_open (DEV_TTY, O_RDWR, 0); | ||
| 635 | if (j >= 0) | ||
| 636 | { | ||
| 637 | ioctl (j, TIOCNOTTY, 0); | ||
| 638 | emacs_close (j); | ||
| 639 | } | ||
| 640 | #else | ||
| 629 | setsid (); | 641 | setsid (); |
| 642 | #endif | ||
| 630 | 643 | ||
| 631 | /* Emacs ignores SIGPIPE, but the child should not. */ | 644 | /* Emacs ignores SIGPIPE, but the child should not. */ |
| 632 | signal (SIGPIPE, SIG_DFL); | 645 | signal (SIGPIPE, SIG_DFL); |
diff --git a/src/conf_post.h b/src/conf_post.h index 30c948e39af..95ebd5511ca 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -99,12 +99,6 @@ typedef bool bool_bf; | |||
| 99 | #define realloc unexec_realloc | 99 | #define realloc unexec_realloc |
| 100 | #define free unexec_free | 100 | #define free unexec_free |
| 101 | #endif | 101 | #endif |
| 102 | /* The following solves the problem that Emacs hangs when evaluating | ||
| 103 | (make-comint "test0" "/nodir/nofile" nil "") when /nodir/nofile | ||
| 104 | does not exist. Also, setsid is not allowed in the vfork child's | ||
| 105 | context as of Darwin 9/Mac OS X 10.5. */ | ||
| 106 | #undef HAVE_WORKING_VFORK | ||
| 107 | #define vfork fork | ||
| 108 | #endif /* DARWIN_OS */ | 102 | #endif /* DARWIN_OS */ |
| 109 | 103 | ||
| 110 | /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use | 104 | /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use |
diff --git a/src/process.c b/src/process.c index b81c7b459e3..0edd092ef66 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) | |||
| 2049 | int volatile forkerr_volatile = forkerr; | 2049 | int volatile forkerr_volatile = forkerr; |
| 2050 | struct Lisp_Process *p_volatile = p; | 2050 | struct Lisp_Process *p_volatile = p; |
| 2051 | 2051 | ||
| 2052 | #ifdef DARWIN_OS | ||
| 2053 | /* Darwin doesn't let us run setsid after a vfork, so use fork when | ||
| 2054 | necessary. */ | ||
| 2055 | if (pty_flag) | ||
| 2056 | pid = fork (); | ||
| 2057 | else | ||
| 2058 | pid = vfork (); | ||
| 2059 | #else | ||
| 2052 | pid = vfork (); | 2060 | pid = vfork (); |
| 2061 | #endif | ||
| 2053 | 2062 | ||
| 2054 | current_dir = current_dir_volatile; | 2063 | current_dir = current_dir_volatile; |
| 2055 | lisp_pty_name = lisp_pty_name_volatile; | 2064 | lisp_pty_name = lisp_pty_name_volatile; |