aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorJan Djärv2003-02-21 18:13:53 +0000
committerJan Djärv2003-02-21 18:13:53 +0000
commit16782258774cc98c69709a16286ed0da91dc25cf (patch)
tree85adb10cfbb3005b99776a97afc73ebffe3f1f0e /src/process.c
parent2d772f45c19f1ec4161b8631c0540e9767ae4e52 (diff)
downloademacs-16782258774cc98c69709a16286ed0da91dc25cf.tar.gz
emacs-16782258774cc98c69709a16286ed0da91dc25cf.zip
Removed subtty, workaround for when TIOCSIGSEND fails.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c71
1 files changed, 45 insertions, 26 deletions
diff --git a/src/process.c b/src/process.c
index 59512bf9441..9790b7d29a6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1782,11 +1782,12 @@ create_process (process, new_argv, current_dir)
1782 chan_process[inchannel] = process; 1782 chan_process[inchannel] = process;
1783 XSETINT (XPROCESS (process)->infd, inchannel); 1783 XSETINT (XPROCESS (process)->infd, inchannel);
1784 XSETINT (XPROCESS (process)->outfd, outchannel); 1784 XSETINT (XPROCESS (process)->outfd, outchannel);
1785 /* Record the tty descriptor used in the subprocess. */ 1785
1786 if (forkin < 0) 1786 /* Previously we recorded the tty descriptor used in the subprocess.
1787 XPROCESS (process)->subtty = Qnil; 1787 It was only used for getting the foreground tty process, so now
1788 else 1788 we just reopen the device (see emacs_get_tty_pgrp) as this is
1789 XSETFASTINT (XPROCESS (process)->subtty, forkin); 1789 more portable (see USG_SUBTTY_WORKS above). */
1790
1790 XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); 1791 XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil);
1791 XPROCESS (process)->status = Qrun; 1792 XPROCESS (process)->status = Qrun;
1792 setup_process_coding_systems (process); 1793 setup_process_coding_systems (process);
@@ -2044,7 +2045,6 @@ create_process (process, new_argv, current_dir)
2044 EMACS_SET_SECS_USECS (offset, 1, 0); 2045 EMACS_SET_SECS_USECS (offset, 1, 0);
2045 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); 2046 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0);
2046 2047
2047 XPROCESS (process)->subtty = Qnil;
2048 if (forkin >= 0) 2048 if (forkin >= 0)
2049 emacs_close (forkin); 2049 emacs_close (forkin);
2050 2050
@@ -5107,6 +5107,33 @@ Output from processes can arrive in between bunches. */)
5107 return Qnil; 5107 return Qnil;
5108} 5108}
5109 5109
5110/* Return the foreground process group for the tty/pty that
5111 the process P uses. */
5112static int
5113emacs_get_tty_pgrp (p)
5114 struct Lisp_Process *p;
5115{
5116 int gid = -1;
5117
5118#ifdef TIOCGPGRP
5119 if (ioctl (XINT (p->infd), TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name))
5120 {
5121 int fd;
5122 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the
5123 master side. Try the slave side. */
5124 fd = emacs_open (XSTRING (p->tty_name)->data, O_RDONLY, 0);
5125
5126 if (fd != -1)
5127 {
5128 ioctl (fd, TIOCGPGRP, &gid);
5129 emacs_close (fd);
5130 }
5131 }
5132#endif /* defined (TIOCGPGRP ) */
5133
5134 return gid;
5135}
5136
5110DEFUN ("process-running-child-p", Fprocess_running_child_p, 5137DEFUN ("process-running-child-p", Fprocess_running_child_p,
5111 Sprocess_running_child_p, 0, 1, 0, 5138 Sprocess_running_child_p, 0, 1, 0,
5112 doc: /* Return t if PROCESS has given the terminal to a child. 5139 doc: /* Return t if PROCESS has given the terminal to a child.
@@ -5117,7 +5144,7 @@ return t unconditionally. */)
5117{ 5144{
5118 /* Initialize in case ioctl doesn't exist or gives an error, 5145 /* Initialize in case ioctl doesn't exist or gives an error,
5119 in a way that will cause returning t. */ 5146 in a way that will cause returning t. */
5120 int gid = 0; 5147 int gid;
5121 Lisp_Object proc; 5148 Lisp_Object proc;
5122 struct Lisp_Process *p; 5149 struct Lisp_Process *p;
5123 5150
@@ -5131,12 +5158,7 @@ return t unconditionally. */)
5131 error ("Process %s is not active", 5158 error ("Process %s is not active",
5132 SDATA (p->name)); 5159 SDATA (p->name));
5133 5160
5134#ifdef TIOCGPGRP 5161 gid = emacs_get_tty_pgrp (p);
5135 if (!NILP (p->subtty))
5136 ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid);
5137 else
5138 ioctl (XINT (p->infd), TIOCGPGRP, &gid);
5139#endif /* defined (TIOCGPGRP ) */
5140 5162
5141 if (gid == XFASTINT (p->pid)) 5163 if (gid == XFASTINT (p->pid))
5142 return Qnil; 5164 return Qnil;
@@ -5288,19 +5310,13 @@ process_send_signal (process, signo, current_group, nomsg)
5288 But, TIOCGPGRP does not work on E50 ;-P works fine on E60" 5310 But, TIOCGPGRP does not work on E50 ;-P works fine on E60"
5289 His patch indicates that if TIOCGPGRP returns an error, then 5311 His patch indicates that if TIOCGPGRP returns an error, then
5290 we should just assume that p->pid is also the process group id. */ 5312 we should just assume that p->pid is also the process group id. */
5291 {
5292 int err;
5293 5313
5294 if (!NILP (p->subtty)) 5314 gid = emacs_get_tty_pgrp (p);
5295 err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); 5315
5296 else 5316 if (gid == -1)
5297 err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); 5317 /* If we can't get the information, assume
5298 5318 the shell owns the tty. */
5299 if (err == -1) 5319 gid = XFASTINT (p->pid);
5300 /* If we can't get the information, assume
5301 the shell owns the tty. */
5302 gid = XFASTINT (p->pid);
5303 }
5304 5320
5305 /* It is not clear whether anything really can set GID to -1. 5321 /* It is not clear whether anything really can set GID to -1.
5306 Perhaps on some system one of those ioctls can or could do so. 5322 Perhaps on some system one of those ioctls can or could do so.
@@ -5362,7 +5378,10 @@ process_send_signal (process, signo, current_group, nomsg)
5362 /* gid may be a pid, or minus a pgrp's number */ 5378 /* gid may be a pid, or minus a pgrp's number */
5363#ifdef TIOCSIGSEND 5379#ifdef TIOCSIGSEND
5364 if (!NILP (current_group)) 5380 if (!NILP (current_group))
5365 ioctl (XINT (p->infd), TIOCSIGSEND, signo); 5381 {
5382 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1)
5383 EMACS_KILLPG (gid, signo);
5384 }
5366 else 5385 else
5367 { 5386 {
5368 gid = - XFASTINT (p->pid); 5387 gid = - XFASTINT (p->pid);