From 322aea6ddf7ec7fd71410d98ec1de69f219aff3e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 31 Oct 2012 10:27:29 -0700 Subject: Fix crash when using Emacs as commit editor for git. * callproc.c (setpgrp): Remove macro, as we now use setpgid and it is configured in conf_post.h. (Fcall_process): Don't invoke both setsid and setpgid; the former is enough, if it exists. * callproc.c (Fcall_process, child_setup): * process.c (create_process): Use setpgid. * conf_post.h (setpgid) [!HAVE_SETPGID]: New macro, which substitutes for the real thing. * dispnew.c (init_display): Initialize the foreground group if we are running a tty display. * emacs.c (main): Do not worry about setpgrp; init_display does it now. * lisp.h (init_foreground_group): New decl. * sysdep.c (inherited_pgroup): New static var. (init_foreground_group, tcsetpgrp_without_stopping) (narrow_foreground_group, widen_foreground_group): New functions. (init_sys_modes): Narrow foreground group. (reset_sys_modes): Widen foreground group. Fixes: debbugs:12697 --- src/process.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index 307e82819d6..77e99ead01f 100644 --- a/src/process.c +++ b/src/process.c @@ -1759,12 +1759,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) #endif } #else /* not HAVE_SETSID */ -#ifdef USG - /* It's very important to call setpgrp here and no time + /* It's very important to call setpgid here and no time afterwards. Otherwise, we lose our controlling tty which is set when we open the pty. */ - setpgrp (); -#endif /* USG */ + setpgid (0, 0); #endif /* not HAVE_SETSID */ #if defined (LDISC1) if (pty_flag && xforkin >= 0) @@ -1802,11 +1800,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) /* In order to get a controlling terminal on some versions of BSD, it is necessary to put the process in pgrp 0 before it opens the terminal. */ -#ifdef HAVE_SETPGID setpgid (0, 0); -#else - setpgrp (0, 0); -#endif #endif } #endif /* TIOCNOTTY */ -- cgit v1.2.1