diff options
| author | Richard M. Stallman | 2002-07-16 13:41:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-07-16 13:41:16 +0000 |
| commit | 2af70a0cffcb27f56ed7ed1b3e8d3fd548b081ef (patch) | |
| tree | 681e88e79725615ddac9bb7c6590c5b2d005775c /src/process.c | |
| parent | 06be4f8589c8be7290b049cc87bb71c6b18f58bf (diff) | |
| download | emacs-2af70a0cffcb27f56ed7ed1b3e8d3fd548b081ef.tar.gz emacs-2af70a0cffcb27f56ed7ed1b3e8d3fd548b081ef.zip | |
(create_process): Test USG_SUBTTY_WORKS.
(process_send_signal): Clean up handling of GID.
Detect errors in ioctls meant to set GID.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/process.c b/src/process.c index df6646e0b62..3554aa2f9cb 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1562,9 +1562,9 @@ create_process (process, new_argv, current_dir) | |||
| 1562 | 1562 | ||
| 1563 | if (inchannel >= 0) | 1563 | if (inchannel >= 0) |
| 1564 | { | 1564 | { |
| 1565 | #ifndef USG | 1565 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1566 | /* On USG systems it does not work to open the pty's tty here | 1566 | /* On most USG systems it does not work to open the pty's tty here, |
| 1567 | and then close and reopen it in the child. */ | 1567 | then close it and reopen it in the child. */ |
| 1568 | #ifdef O_NOCTTY | 1568 | #ifdef O_NOCTTY |
| 1569 | /* Don't let this terminal become our controlling terminal | 1569 | /* Don't let this terminal become our controlling terminal |
| 1570 | (in case we don't have one). */ | 1570 | (in case we don't have one). */ |
| @@ -1576,7 +1576,7 @@ create_process (process, new_argv, current_dir) | |||
| 1576 | report_file_error ("Opening pty", Qnil); | 1576 | report_file_error ("Opening pty", Qnil); |
| 1577 | #else | 1577 | #else |
| 1578 | forkin = forkout = -1; | 1578 | forkin = forkout = -1; |
| 1579 | #endif /* not USG */ | 1579 | #endif /* not USG, or USG_SUBTTY_WORKS */ |
| 1580 | pty_flag = 1; | 1580 | pty_flag = 1; |
| 1581 | } | 1581 | } |
| 1582 | else | 1582 | else |
| @@ -5027,7 +5027,10 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5027 | current_group = Qnil; | 5027 | current_group = Qnil; |
| 5028 | 5028 | ||
| 5029 | /* If we are using pgrps, get a pgrp number and make it negative. */ | 5029 | /* If we are using pgrps, get a pgrp number and make it negative. */ |
| 5030 | if (!NILP (current_group)) | 5030 | if (NILP (current_group)) |
| 5031 | /* Send the signal to the shell's process group. */ | ||
| 5032 | gid = XFASTINT (p->pid); | ||
| 5033 | else | ||
| 5031 | { | 5034 | { |
| 5032 | #ifdef SIGNALS_VIA_CHARACTERS | 5035 | #ifdef SIGNALS_VIA_CHARACTERS |
| 5033 | /* If possible, send signals to the entire pgrp | 5036 | /* If possible, send signals to the entire pgrp |
| @@ -5122,7 +5125,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5122 | #endif /* defined (SIGNALS_VIA_CHARACTERS) */ | 5125 | #endif /* defined (SIGNALS_VIA_CHARACTERS) */ |
| 5123 | 5126 | ||
| 5124 | #ifdef TIOCGPGRP | 5127 | #ifdef TIOCGPGRP |
| 5125 | /* Get the pgrp using the tty itself, if we have that. | 5128 | /* Get the current pgrp using the tty itself, if we have that. |
| 5126 | Otherwise, use the pty to get the pgrp. | 5129 | Otherwise, use the pty to get the pgrp. |
| 5127 | On pfa systems, saka@pfu.fujitsu.co.JP writes: | 5130 | On pfa systems, saka@pfu.fujitsu.co.JP writes: |
| 5128 | "TIOCGPGRP symbol defined in sys/ioctl.h at E50. | 5131 | "TIOCGPGRP symbol defined in sys/ioctl.h at E50. |
| @@ -5137,28 +5140,28 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5137 | else | 5140 | else |
| 5138 | err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); | 5141 | err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); |
| 5139 | 5142 | ||
| 5140 | #ifdef pfa | ||
| 5141 | if (err == -1) | 5143 | if (err == -1) |
| 5142 | gid = - XFASTINT (p->pid); | 5144 | /* If we can't get the information, assume |
| 5143 | #endif /* ! defined (pfa) */ | 5145 | the shell owns the tty. */ |
| 5146 | gid = XFASTINT (p->pid); | ||
| 5144 | } | 5147 | } |
| 5148 | |||
| 5149 | /* It is not clear whether anything really can set GID to -1. | ||
| 5150 | Perhaps on some system one of those ioctls can or could do so. | ||
| 5151 | Or perhaps this is vestigial. */ | ||
| 5145 | if (gid == -1) | 5152 | if (gid == -1) |
| 5146 | no_pgrp = 1; | 5153 | no_pgrp = 1; |
| 5147 | else | ||
| 5148 | gid = - gid; | ||
| 5149 | #else /* ! defined (TIOCGPGRP ) */ | 5154 | #else /* ! defined (TIOCGPGRP ) */ |
| 5150 | /* Can't select pgrps on this system, so we know that | 5155 | /* Can't select pgrps on this system, so we know that |
| 5151 | the child itself heads the pgrp. */ | 5156 | the child itself heads the pgrp. */ |
| 5152 | gid = - XFASTINT (p->pid); | 5157 | gid = XFASTINT (p->pid); |
| 5153 | #endif /* ! defined (TIOCGPGRP ) */ | 5158 | #endif /* ! defined (TIOCGPGRP ) */ |
| 5154 | 5159 | ||
| 5155 | /* If current_group is lambda, and the shell owns the terminal, | 5160 | /* If current_group is lambda, and the shell owns the terminal, |
| 5156 | don't send any signal. */ | 5161 | don't send any signal. */ |
| 5157 | if (EQ (current_group, Qlambda) && gid == - XFASTINT (p->pid)) | 5162 | if (EQ (current_group, Qlambda) && gid == XFASTINT (p->pid)) |
| 5158 | return; | 5163 | return; |
| 5159 | } | 5164 | } |
| 5160 | else | ||
| 5161 | gid = - XFASTINT (p->pid); | ||
| 5162 | 5165 | ||
| 5163 | switch (signo) | 5166 | switch (signo) |
| 5164 | { | 5167 | { |
| @@ -5210,7 +5213,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 5210 | kill (gid, signo); | 5213 | kill (gid, signo); |
| 5211 | } | 5214 | } |
| 5212 | #else /* ! defined (TIOCSIGSEND) */ | 5215 | #else /* ! defined (TIOCSIGSEND) */ |
| 5213 | EMACS_KILLPG (-gid, signo); | 5216 | EMACS_KILLPG (gid, signo); |
| 5214 | #endif /* ! defined (TIOCSIGSEND) */ | 5217 | #endif /* ! defined (TIOCSIGSEND) */ |
| 5215 | } | 5218 | } |
| 5216 | 5219 | ||