diff options
| author | Richard M. Stallman | 1993-09-08 16:55:53 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-09-08 16:55:53 +0000 |
| commit | 64e971c33be459710a200492cf1e398197828095 (patch) | |
| tree | f7183e277cbd07a621c6460d330a368a7f00d010 /src | |
| parent | 953d263ecdca7f93653693ecf8b70bb5f6f11480 (diff) | |
| download | emacs-64e971c33be459710a200492cf1e398197828095.tar.gz emacs-64e971c33be459710a200492cf1e398197828095.zip | |
(stuff_char): Use input_fd.
(narrow_foreground_group, widen_foreground_group, init_sys_modes)
(init_baud_rate, init_sigio, request_sigio, unrequest_sigio): Likewise.
(change_input_fd): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sysdep.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index cda2b8f3a47..6cb5e1c8340 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -168,10 +168,21 @@ static int baud_convert[] = | |||
| 168 | extern short ospeed; | 168 | extern short ospeed; |
| 169 | 169 | ||
| 170 | /* The file descriptor for Emacs's input terminal. | 170 | /* The file descriptor for Emacs's input terminal. |
| 171 | Under Unix, this is always left zero; | 171 | Under Unix, this is normaly zero except when using X; |
| 172 | under VMS, we place the input channel number here. | 172 | under VMS, we place the input channel number here. |
| 173 | This allows us to write more code that works for both VMS and Unix. */ | 173 | This allows us to write more code that works for both VMS and Unix. */ |
| 174 | static int input_fd; | 174 | static int input_fd; |
| 175 | |||
| 176 | /* Specify a different file descriptor for further input operations. */ | ||
| 177 | |||
| 178 | void | ||
| 179 | change_input_fd (fd) | ||
| 180 | int fd; | ||
| 181 | { | ||
| 182 | input_fd = fd; | ||
| 183 | } | ||
| 184 | |||
| 185 | /* Discard pending input on descriptor input_fd. */ | ||
| 175 | 186 | ||
| 176 | discard_tty_input () | 187 | discard_tty_input () |
| 177 | { | 188 | { |
| @@ -194,7 +205,7 @@ discard_tty_input () | |||
| 194 | #ifdef APOLLO | 205 | #ifdef APOLLO |
| 195 | { | 206 | { |
| 196 | int zero = 0; | 207 | int zero = 0; |
| 197 | ioctl (0, TIOCFLUSH, &zero); | 208 | ioctl (input_fd, TIOCFLUSH, &zero); |
| 198 | } | 209 | } |
| 199 | #else /* not Apollo */ | 210 | #else /* not Apollo */ |
| 200 | EMACS_GET_TTY (input_fd, &buf); | 211 | EMACS_GET_TTY (input_fd, &buf); |
| @@ -205,19 +216,22 @@ discard_tty_input () | |||
| 205 | 216 | ||
| 206 | #ifdef SIGTSTP | 217 | #ifdef SIGTSTP |
| 207 | 218 | ||
| 219 | /* Arrange for character C to be read as the next input from | ||
| 220 | the terminal. */ | ||
| 221 | |||
| 208 | stuff_char (c) | 222 | stuff_char (c) |
| 209 | char c; | 223 | char c; |
| 210 | { | 224 | { |
| 211 | /* Should perhaps error if in batch mode */ | 225 | /* Should perhaps error if in batch mode */ |
| 212 | #ifdef TIOCSTI | 226 | #ifdef TIOCSTI |
| 213 | ioctl (0, TIOCSTI, &c); | 227 | ioctl (input_fd, TIOCSTI, &c); |
| 214 | #else /* no TIOCSTI */ | 228 | #else /* no TIOCSTI */ |
| 215 | error ("Cannot stuff terminal input characters in this version of Unix."); | 229 | error ("Cannot stuff terminal input characters in this version of Unix."); |
| 216 | #endif /* no TIOCSTI */ | 230 | #endif /* no TIOCSTI */ |
| 217 | } | 231 | } |
| 218 | 232 | ||
| 219 | #endif /* SIGTSTP */ | 233 | #endif /* SIGTSTP */ |
| 220 | 234 | ||
| 221 | init_baud_rate () | 235 | init_baud_rate () |
| 222 | { | 236 | { |
| 223 | if (noninteractive) | 237 | if (noninteractive) |
| @@ -235,7 +249,7 @@ init_baud_rate () | |||
| 235 | struct termios sg; | 249 | struct termios sg; |
| 236 | 250 | ||
| 237 | sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; | 251 | sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; |
| 238 | tcgetattr (0, &sg); | 252 | tcgetattr (input_fd, &sg); |
| 239 | ospeed = cfgetospeed (&sg); | 253 | ospeed = cfgetospeed (&sg); |
| 240 | #else /* neither VMS nor TERMIOS */ | 254 | #else /* neither VMS nor TERMIOS */ |
| 241 | #ifdef HAVE_TERMIO | 255 | #ifdef HAVE_TERMIO |
| @@ -243,7 +257,7 @@ init_baud_rate () | |||
| 243 | 257 | ||
| 244 | sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; | 258 | sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; |
| 245 | #ifdef HAVE_TCATTR | 259 | #ifdef HAVE_TCATTR |
| 246 | tcgetattr (0, &sg); | 260 | tcgetattr (input_fd, &sg); |
| 247 | #else | 261 | #else |
| 248 | ioctl (input_fd, TCGETA, &sg); | 262 | ioctl (input_fd, TCGETA, &sg); |
| 249 | #endif | 263 | #endif |
| @@ -252,7 +266,7 @@ init_baud_rate () | |||
| 252 | struct sgttyb sg; | 266 | struct sgttyb sg; |
| 253 | 267 | ||
| 254 | sg.sg_ospeed = B9600; | 268 | sg.sg_ospeed = B9600; |
| 255 | if (ioctl (0, TIOCGETP, &sg) < 0) | 269 | if (ioctl (input_fd, TIOCGETP, &sg) < 0) |
| 256 | abort (); | 270 | abort (); |
| 257 | ospeed = sg.sg_ospeed; | 271 | ospeed = sg.sg_ospeed; |
| 258 | #endif /* not HAVE_TERMIO */ | 272 | #endif /* not HAVE_TERMIO */ |
| @@ -275,7 +289,7 @@ set_exclusive_use (fd) | |||
| 275 | #endif | 289 | #endif |
| 276 | /* Ok to do nothing if this feature does not exist */ | 290 | /* Ok to do nothing if this feature does not exist */ |
| 277 | } | 291 | } |
| 278 | 292 | ||
| 279 | #ifndef subprocesses | 293 | #ifndef subprocesses |
| 280 | 294 | ||
| 281 | wait_without_blocking () | 295 | wait_without_blocking () |
| @@ -408,7 +422,7 @@ flush_pending_output (channel) | |||
| 408 | #endif | 422 | #endif |
| 409 | #endif | 423 | #endif |
| 410 | } | 424 | } |
| 411 | 425 | ||
| 412 | #ifndef VMS | 426 | #ifndef VMS |
| 413 | /* Set up the terminal at the other end of a pseudo-terminal that | 427 | /* Set up the terminal at the other end of a pseudo-terminal that |
| 414 | we will be controlling an inferior through. | 428 | we will be controlling an inferior through. |
| @@ -509,7 +523,7 @@ setpgrp_of_tty (pid) | |||
| 509 | { | 523 | { |
| 510 | EMACS_SET_TTY_PGRP (input_fd, &pid); | 524 | EMACS_SET_TTY_PGRP (input_fd, &pid); |
| 511 | } | 525 | } |
| 512 | 526 | ||
| 513 | /* Record a signal code and the handler for it. */ | 527 | /* Record a signal code and the handler for it. */ |
| 514 | struct save_signal | 528 | struct save_signal |
| 515 | { | 529 | { |
| @@ -686,7 +700,7 @@ int old_fcntl_flags; | |||
| 686 | init_sigio () | 700 | init_sigio () |
| 687 | { | 701 | { |
| 688 | #ifdef FASYNC | 702 | #ifdef FASYNC |
| 689 | old_fcntl_flags = fcntl (0, F_GETFL, 0) & ~FASYNC; | 703 | old_fcntl_flags = fcntl (input_fd, F_GETFL, 0) & ~FASYNC; |
| 690 | #endif | 704 | #endif |
| 691 | request_sigio (); | 705 | request_sigio (); |
| 692 | } | 706 | } |
| @@ -703,7 +717,7 @@ request_sigio () | |||
| 703 | #ifdef SIGWINCH | 717 | #ifdef SIGWINCH |
| 704 | sigunblock (sigmask (SIGWINCH)); | 718 | sigunblock (sigmask (SIGWINCH)); |
| 705 | #endif | 719 | #endif |
| 706 | fcntl (0, F_SETFL, old_fcntl_flags | FASYNC); | 720 | fcntl (input_fd, F_SETFL, old_fcntl_flags | FASYNC); |
| 707 | 721 | ||
| 708 | interrupts_deferred = 0; | 722 | interrupts_deferred = 0; |
| 709 | } | 723 | } |
| @@ -713,7 +727,7 @@ unrequest_sigio () | |||
| 713 | #ifdef SIGWINCH | 727 | #ifdef SIGWINCH |
| 714 | sigblock (sigmask (SIGWINCH)); | 728 | sigblock (sigmask (SIGWINCH)); |
| 715 | #endif | 729 | #endif |
| 716 | fcntl (0, F_SETFL, old_fcntl_flags); | 730 | fcntl (input_fd, F_SETFL, old_fcntl_flags); |
| 717 | interrupts_deferred = 1; | 731 | interrupts_deferred = 1; |
| 718 | } | 732 | } |
| 719 | 733 | ||
| @@ -723,7 +737,7 @@ unrequest_sigio () | |||
| 723 | request_sigio () | 737 | request_sigio () |
| 724 | { | 738 | { |
| 725 | int on = 1; | 739 | int on = 1; |
| 726 | ioctl (0, FIOASYNC, &on); | 740 | ioctl (input_fd, FIOASYNC, &on); |
| 727 | interrupts_deferred = 0; | 741 | interrupts_deferred = 0; |
| 728 | } | 742 | } |
| 729 | 743 | ||
| @@ -731,7 +745,7 @@ unrequest_sigio () | |||
| 731 | { | 745 | { |
| 732 | int off = 0; | 746 | int off = 0; |
| 733 | 747 | ||
| 734 | ioctl (0, FIOASYNC, &off); | 748 | ioctl (input_fd, FIOASYNC, &off); |
| 735 | interrupts_deferred = 1; | 749 | interrupts_deferred = 1; |
| 736 | } | 750 | } |
| 737 | 751 | ||
| @@ -785,7 +799,7 @@ narrow_foreground_group () | |||
| 785 | 799 | ||
| 786 | setpgrp (0, inherited_pgroup); | 800 | setpgrp (0, inherited_pgroup); |
| 787 | if (inherited_pgroup != me) | 801 | if (inherited_pgroup != me) |
| 788 | EMACS_SET_TTY_PGRP (0, &me); | 802 | EMACS_SET_TTY_PGRP (input_fd, &me); |
| 789 | setpgrp (0, me); | 803 | setpgrp (0, me); |
| 790 | } | 804 | } |
| 791 | 805 | ||
| @@ -793,7 +807,7 @@ narrow_foreground_group () | |||
| 793 | widen_foreground_group () | 807 | widen_foreground_group () |
| 794 | { | 808 | { |
| 795 | if (inherited_pgroup != getpid ()) | 809 | if (inherited_pgroup != getpid ()) |
| 796 | EMACS_SET_TTY_PGRP (0, &inherited_pgroup); | 810 | EMACS_SET_TTY_PGRP (input_fd, &inherited_pgroup); |
| 797 | setpgrp (0, inherited_pgroup); | 811 | setpgrp (0, inherited_pgroup); |
| 798 | } | 812 | } |
| 799 | 813 | ||
| @@ -1189,11 +1203,11 @@ init_sys_modes () | |||
| 1189 | we have an unlocked terminal at the start. */ | 1203 | we have an unlocked terminal at the start. */ |
| 1190 | 1204 | ||
| 1191 | #ifdef TCXONC | 1205 | #ifdef TCXONC |
| 1192 | if (!flow_control) ioctl (0, TCXONC, 1); | 1206 | if (!flow_control) ioctl (input_fd, TCXONC, 1); |
| 1193 | #endif | 1207 | #endif |
| 1194 | #ifndef APOLLO | 1208 | #ifndef APOLLO |
| 1195 | #ifdef TIOCSTART | 1209 | #ifdef TIOCSTART |
| 1196 | if (!flow_control) ioctl (0, TIOCSTART, 0); | 1210 | if (!flow_control) ioctl (input_fd, TIOCSTART, 0); |
| 1197 | #endif | 1211 | #endif |
| 1198 | #endif | 1212 | #endif |
| 1199 | 1213 | ||
| @@ -1225,8 +1239,8 @@ init_sys_modes () | |||
| 1225 | #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ | 1239 | #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ |
| 1226 | if (interrupt_input) | 1240 | if (interrupt_input) |
| 1227 | { | 1241 | { |
| 1228 | old_fcntl_owner = fcntl (0, F_GETOWN, 0); | 1242 | old_fcntl_owner = fcntl (input_fd, F_GETOWN, 0); |
| 1229 | fcntl (0, F_SETOWN, getpid ()); | 1243 | fcntl (input_fd, F_SETOWN, getpid ()); |
| 1230 | init_sigio (); | 1244 | init_sigio (); |
| 1231 | } | 1245 | } |
| 1232 | #endif /* F_GETOWN */ | 1246 | #endif /* F_GETOWN */ |
| @@ -1377,7 +1391,7 @@ reset_sys_modes () | |||
| 1377 | if (interrupt_input) | 1391 | if (interrupt_input) |
| 1378 | { | 1392 | { |
| 1379 | reset_sigio (); | 1393 | reset_sigio (); |
| 1380 | fcntl (0, F_SETOWN, old_fcntl_owner); | 1394 | fcntl (input_fd, F_SETOWN, old_fcntl_owner); |
| 1381 | } | 1395 | } |
| 1382 | #endif /* F_SETOWN */ | 1396 | #endif /* F_SETOWN */ |
| 1383 | #endif /* F_SETOWN_BUG */ | 1397 | #endif /* F_SETOWN_BUG */ |