aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-10-31 10:27:29 -0700
committerPaul Eggert2012-10-31 10:27:29 -0700
commit322aea6ddf7ec7fd71410d98ec1de69f219aff3e (patch)
tree5efe99d41566350e9793015cde6ebb656e1278e6 /src/callproc.c
parent220cb2bd70c65041417554cc2dc10edb4a53de5c (diff)
downloademacs-322aea6ddf7ec7fd71410d98ec1de69f219aff3e.tar.gz
emacs-322aea6ddf7ec7fd71410d98ec1de69f219aff3e.zip
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
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/callproc.c b/src/callproc.c
index b33882e54c2..c236f22fc86 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -64,13 +64,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
64#include "nsterm.h" 64#include "nsterm.h"
65#endif 65#endif
66 66
67#ifdef HAVE_SETPGID
68#if !defined (USG)
69#undef setpgrp
70#define setpgrp setpgid
71#endif
72#endif
73
74/* Pattern used by call-process-region to make temp files. */ 67/* Pattern used by call-process-region to make temp files. */
75static Lisp_Object Vtemp_file_name_pattern; 68static Lisp_Object Vtemp_file_name_pattern;
76 69
@@ -618,14 +611,12 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
618 { 611 {
619 if (fd[0] >= 0) 612 if (fd[0] >= 0)
620 emacs_close (fd[0]); 613 emacs_close (fd[0]);
614
621#ifdef HAVE_SETSID 615#ifdef HAVE_SETSID
622 setsid (); 616 setsid ();
623#endif
624#if defined (USG)
625 setpgrp ();
626#else 617#else
627 setpgrp (pid, pid); 618 setpgid (0, 0);
628#endif /* USG */ 619#endif
629 620
630 /* Emacs ignores SIGPIPE, but the child should not. */ 621 /* Emacs ignores SIGPIPE, but the child should not. */
631 signal (SIGPIPE, SIG_DFL); 622 signal (SIGPIPE, SIG_DFL);
@@ -1295,13 +1286,9 @@ child_setup (int in, int out, int err, char **new_argv, bool set_pgrp,
1295 if (err != in && err != out) 1286 if (err != in && err != out)
1296 emacs_close (err); 1287 emacs_close (err);
1297 1288
1298#if defined (USG) 1289#if defined HAVE_SETPGID || ! (defined USG && defined SETPGRP_RELEASES_CTTY)
1299#ifndef SETPGRP_RELEASES_CTTY 1290 setpgid (pid, pid);
1300 setpgrp (); /* No arguments but equivalent in this case */
1301#endif 1291#endif
1302#else /* not USG */
1303 setpgrp (pid, pid);
1304#endif /* not USG */
1305 1292
1306 /* setpgrp_of_tty is incorrect here; it uses input_fd. */ 1293 /* setpgrp_of_tty is incorrect here; it uses input_fd. */
1307 tcsetpgrp (0, pid); 1294 tcsetpgrp (0, pid);