Mercurial > emacs
annotate src/sysdep.c @ 5020:94de08fd8a7c
(Fnext_single_property_change): Fix missing \n\.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 15 Nov 1993 06:41:45 +0000 |
| parents | 8d58e388e71b |
| children | 500f269bf0a8 |
| rev | line source |
|---|---|
| 491 | 1 /* Interfaces to system-dependent kernel and library entries. |
| 2961 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1993 Free Software Foundation, Inc. |
| 491 | 3 |
| 4 This file is part of GNU Emacs. | |
| 5 | |
| 6 GNU Emacs is free software; you can redistribute it and/or modify | |
| 7 it under the terms of the GNU General Public License as published by | |
| 8 the Free Software Foundation; either version 1, or (at your option) | |
| 9 any later version. | |
| 10 | |
| 11 GNU Emacs is distributed in the hope that it will be useful, | |
| 12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 GNU General Public License for more details. | |
| 15 | |
| 16 You should have received a copy of the GNU General Public License | |
| 17 along with GNU Emacs; see the file COPYING. If not, write to | |
| 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
| 19 | |
| 20 | |
| 21 #include <signal.h> | |
| 22 #include <setjmp.h> | |
| 23 | |
|
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4681
diff
changeset
|
24 #include <config.h> |
| 491 | 25 #include "lisp.h" |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
26 #include "blockinput.h" |
| 491 | 27 #undef NULL |
| 28 | |
| 29 #define min(x,y) ((x) > (y) ? (y) : (x)) | |
| 30 | |
| 31 /* In this file, open, read and write refer to the system calls, | |
| 32 not our sugared interfaces sys_open, sys_read and sys_write. | |
| 33 Contrariwise, for systems where we use the system calls directly, | |
| 34 define sys_read, etc. here as aliases for them. */ | |
| 35 #ifndef read | |
| 36 #define sys_read read | |
| 37 #define sys_write write | |
| 38 #endif /* `read' is not a macro */ | |
| 39 | |
| 40 #undef read | |
| 41 #undef write | |
| 42 | |
| 43 #ifndef close | |
| 44 #define sys_close close | |
| 45 #else | |
| 46 #undef close | |
| 47 #endif | |
| 48 | |
| 49 #ifndef open | |
| 50 #define sys_open open | |
| 51 #else /* `open' is a macro */ | |
| 52 #undef open | |
| 53 #endif /* `open' is a macro */ | |
| 54 | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
55 /* Does anyone other than VMS need this? */ |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
56 #ifndef fwrite |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
57 #define sys_fwrite fwrite |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
58 #else |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
59 #undef fwrite |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
60 #endif |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
61 |
| 491 | 62 #include <stdio.h> |
| 63 #include <sys/types.h> | |
| 64 #include <sys/stat.h> | |
| 65 #include <errno.h> | |
| 66 | |
| 67 extern int errno; | |
| 68 #ifndef VMS | |
| 69 extern char *sys_errlist[]; | |
| 70 #endif | |
| 71 | |
| 72 #ifdef VMS | |
| 73 #include <rms.h> | |
| 74 #include <ttdef.h> | |
| 75 #include <tt2def.h> | |
| 76 #include <iodef.h> | |
| 77 #include <ssdef.h> | |
| 78 #include <descrip.h> | |
| 79 #include <fibdef.h> | |
| 80 #include <atrdef.h> | |
| 81 #include <ctype.h> | |
| 82 #include <string.h> | |
| 83 #ifdef __GNUC__ | |
| 84 #include <sys/file.h> | |
| 85 #else | |
| 86 #include <file.h> | |
| 87 #endif | |
| 88 #undef F_SETFL | |
| 89 #ifndef RAB$C_BID | |
| 90 #include <rab.h> | |
| 91 #endif | |
| 92 #define MAXIOSIZE ( 32 * PAGESIZE ) /* Don't I/O more than 32 blocks at a time */ | |
| 93 #endif /* VMS */ | |
| 94 | |
| 95 #ifndef BSD4_1 | |
| 96 #ifdef BSD /* this is done this way to avoid defined (BSD) || defined (USG) | |
| 97 because the vms compiler doesn't grok `defined' */ | |
| 98 #include <fcntl.h> | |
| 99 #endif | |
| 100 #ifdef USG | |
|
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
101 #ifndef USG5 |
| 491 | 102 #include <fcntl.h> |
| 103 #endif | |
|
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
104 #endif |
| 491 | 105 #endif /* not 4.1 bsd */ |
| 106 | |
|
3604
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
107 #ifdef BROKEN_FASYNC |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
108 /* On some systems (DGUX comes to mind real fast) FASYNC causes |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
109 background writes to the terminal to stop all processes in the |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
110 process group when invoked under the csh (and probably any shell |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
111 with job control). This stops Emacs dead in its tracks when coming |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
112 up under X11. */ |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
113 #undef FASYNC |
|
be31c90ee59d
* sysdep.c: Remove clause for DGUX support of FASYNC; add clause
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
114 #endif |
| 491 | 115 |
| 116 #include <sys/ioctl.h> | |
|
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
117 #include "systty.h" |
| 4640 | 118 #include "syswait.h" |
| 491 | 119 |
| 120 #ifdef BROKEN_TIOCGWINSZ | |
| 121 #undef TIOCGWINSZ | |
| 122 #endif | |
| 123 | |
| 124 #ifdef USG | |
| 125 #include <sys/utsname.h> | |
| 126 #include <string.h> | |
| 127 #ifndef MEMORY_IN_STRING_H | |
| 128 #include <memory.h> | |
| 129 #endif | |
| 130 #ifdef TIOCGWINSZ | |
| 131 #ifdef NEED_SIOCTL | |
| 132 #include <sys/sioctl.h> | |
| 133 #endif | |
| 134 #ifdef NEED_PTEM_H | |
| 135 #include <sys/stream.h> | |
| 136 #include <sys/ptem.h> | |
| 137 #endif | |
| 138 #endif /* TIOCGWINSZ */ | |
| 139 #endif /* USG */ | |
| 140 | |
| 141 extern int quit_char; | |
| 142 | |
| 766 | 143 #include "frame.h" |
| 491 | 144 #include "window.h" |
| 145 #include "termhooks.h" | |
| 146 #include "termchar.h" | |
| 147 #include "termopts.h" | |
| 148 #include "dispextern.h" | |
| 149 #include "process.h" | |
| 150 | |
| 151 #ifdef NONSYSTEM_DIR_LIBRARY | |
| 152 #include "ndir.h" | |
| 153 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
| 154 | |
| 579 | 155 #include "syssignal.h" |
| 156 #include "systime.h" | |
| 491 | 157 |
|
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
158 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
159 #ifndef LPASS8 |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
160 #define LPASS8 0 |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
161 #endif |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
162 |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
163 #ifdef BSD4_1 |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
164 #define LNOFLSH 0100000 |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
165 #endif |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
166 |
| 491 | 167 static int baud_convert[] = |
| 168 #ifdef BAUD_CONVERT | |
| 169 BAUD_CONVERT; | |
| 170 #else | |
| 171 { | |
| 172 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, | |
| 173 1800, 2400, 4800, 9600, 19200, 38400 | |
| 174 }; | |
| 175 #endif | |
| 176 | |
| 177 extern short ospeed; | |
| 178 | |
| 579 | 179 /* The file descriptor for Emacs's input terminal. |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
180 Under Unix, this is normaly zero except when using X; |
| 579 | 181 under VMS, we place the input channel number here. |
| 182 This allows us to write more code that works for both VMS and Unix. */ | |
| 183 static int input_fd; | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
184 |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
185 /* Specify a different file descriptor for further input operations. */ |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
186 |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
187 void |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
188 change_input_fd (fd) |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
189 int fd; |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
190 { |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
191 input_fd = fd; |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
192 } |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
193 |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
194 /* Discard pending input on descriptor input_fd. */ |
| 579 | 195 |
| 491 | 196 discard_tty_input () |
| 197 { | |
| 579 | 198 struct emacs_tty buf; |
| 491 | 199 |
| 200 if (noninteractive) | |
| 201 return; | |
| 202 | |
| 203 /* Discarding input is not safe when the input could contain | |
| 204 replies from the X server. So don't do it. */ | |
| 205 if (read_socket_hook) | |
| 206 return; | |
| 207 | |
| 208 #ifdef VMS | |
| 209 end_kbd_input (); | |
| 579 | 210 SYS$QIOW (0, input_fd, IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, |
| 211 &buf.main, 0, 0, terminator_mask, 0, 0); | |
| 491 | 212 queue_kbd_input (); |
| 213 #else /* not VMS */ | |
| 214 #ifdef APOLLO | |
| 215 { | |
| 216 int zero = 0; | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
217 ioctl (input_fd, TIOCFLUSH, &zero); |
| 491 | 218 } |
| 219 #else /* not Apollo */ | |
| 579 | 220 EMACS_GET_TTY (input_fd, &buf); |
| 221 EMACS_SET_TTY (input_fd, &buf, 0); | |
| 491 | 222 #endif /* not Apollo */ |
| 223 #endif /* not VMS */ | |
| 224 } | |
| 225 | |
| 226 #ifdef SIGTSTP | |
| 227 | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
228 /* Arrange for character C to be read as the next input from |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
229 the terminal. */ |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
230 |
| 491 | 231 stuff_char (c) |
| 232 char c; | |
| 233 { | |
| 234 /* Should perhaps error if in batch mode */ | |
| 235 #ifdef TIOCSTI | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
236 ioctl (input_fd, TIOCSTI, &c); |
| 491 | 237 #else /* no TIOCSTI */ |
| 238 error ("Cannot stuff terminal input characters in this version of Unix."); | |
| 239 #endif /* no TIOCSTI */ | |
| 240 } | |
| 241 | |
| 242 #endif /* SIGTSTP */ | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
243 |
| 491 | 244 init_baud_rate () |
| 245 { | |
| 246 if (noninteractive) | |
| 247 ospeed = 0; | |
| 248 else | |
| 249 { | |
| 250 #ifdef VMS | |
| 579 | 251 struct sensemode sg; |
| 252 | |
| 253 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0, | |
| 491 | 254 &sg.class, 12, 0, 0, 0, 0 ); |
| 579 | 255 ospeed = sg.xmit_baud; |
| 256 #else /* not VMS */ | |
| 257 #ifdef HAVE_TERMIOS | |
| 258 struct termios sg; | |
| 259 | |
| 260 sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
261 tcgetattr (input_fd, &sg); |
|
3559
a9b886b3f976
(init_baud_rate) [HAVE_TERMIOS]: Use cfgetospeed.
Richard M. Stallman <rms@gnu.org>
parents:
3472
diff
changeset
|
262 ospeed = cfgetospeed (&sg); |
|
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
263 #else /* neither VMS nor TERMIOS */ |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
264 #ifdef HAVE_TERMIO |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
265 struct termio sg; |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
266 |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
267 sg.c_cflag = (sg.c_cflag & ~CBAUD) | B9600; |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
268 #ifdef HAVE_TCATTR |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
269 tcgetattr (input_fd, &sg); |
|
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
270 #else |
|
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
271 ioctl (input_fd, TCGETA, &sg); |
|
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
272 #endif |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
273 ospeed = sg.c_cflag & CBAUD; |
|
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
274 #else /* neither VMS nor TERMIOS nor TERMIO */ |
| 579 | 275 struct sgttyb sg; |
| 276 | |
| 277 sg.sg_ospeed = B9600; | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
278 if (ioctl (input_fd, TIOCGETP, &sg) < 0) |
|
3559
a9b886b3f976
(init_baud_rate) [HAVE_TERMIOS]: Use cfgetospeed.
Richard M. Stallman <rms@gnu.org>
parents:
3472
diff
changeset
|
279 abort (); |
| 579 | 280 ospeed = sg.sg_ospeed; |
|
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
281 #endif /* not HAVE_TERMIO */ |
| 579 | 282 #endif /* not HAVE_TERMIOS */ |
| 491 | 283 #endif /* not VMS */ |
| 284 } | |
| 285 | |
| 286 baud_rate = (ospeed < sizeof baud_convert / sizeof baud_convert[0] | |
| 287 ? baud_convert[ospeed] : 9600); | |
| 288 if (baud_rate == 0) | |
| 289 baud_rate = 1200; | |
| 290 } | |
| 291 | |
| 292 /*ARGSUSED*/ | |
| 293 set_exclusive_use (fd) | |
| 294 int fd; | |
| 295 { | |
| 296 #ifdef FIOCLEX | |
| 297 ioctl (fd, FIOCLEX, 0); | |
| 298 #endif | |
| 299 /* Ok to do nothing if this feature does not exist */ | |
| 300 } | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
301 |
| 491 | 302 #ifndef subprocesses |
| 303 | |
| 304 wait_without_blocking () | |
| 305 { | |
| 306 #ifdef BSD | |
| 307 wait3 (0, WNOHANG | WUNTRACED, 0); | |
| 308 #else | |
| 309 croak ("wait_without_blocking"); | |
| 310 #endif | |
| 311 synch_process_alive = 0; | |
| 312 } | |
| 313 | |
| 314 #endif /* not subprocesses */ | |
| 315 | |
| 316 int wait_debugging; /* Set nonzero to make following function work under dbx | |
| 317 (at least for bsd). */ | |
| 318 | |
| 319 SIGTYPE | |
| 320 wait_for_termination_signal () | |
| 321 {} | |
| 322 | |
| 323 /* Wait for subprocess with process id `pid' to terminate and | |
| 324 make sure it will get eliminated (not remain forever as a zombie) */ | |
| 325 | |
| 326 wait_for_termination (pid) | |
| 327 int pid; | |
| 328 { | |
| 329 while (1) | |
| 330 { | |
| 331 #ifdef subprocesses | |
| 332 #ifdef VMS | |
| 333 int status; | |
| 334 | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
335 status = SYS$FORCEX (&pid, 0, 0); |
| 491 | 336 break; |
| 337 #else /* not VMS */ | |
|
3334
7900edb84c4f
(wait_for_termination): Delete LINUX conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
3321
diff
changeset
|
338 #if defined (BSD) || (defined (HPUX) && !defined (HPUX_5)) |
|
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
339 /* Note that kill returns -1 even if the process is just a zombie now. |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
340 But inevitably a SIGCHLD interrupt should be generated |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
341 and child_sig will do wait3 and make the process go away. */ |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
342 /* There is some indication that there is a bug involved with |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
343 termination of subprocesses, perhaps involving a kernel bug too, |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
344 but no idea what it is. Just as a hunch we signal SIGCHLD to see |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
345 if that causes the problem to go away or get worse. */ |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
346 sigsetmask (sigmask (SIGCHLD)); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
347 if (0 > kill (pid, 0)) |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
348 { |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
349 sigsetmask (SIGEMPTYMASK); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
350 kill (getpid (), SIGCHLD); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
351 break; |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
352 } |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
353 if (wait_debugging) |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
354 sleep (1); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
355 else |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
356 sigpause (SIGEMPTYMASK); |
|
3334
7900edb84c4f
(wait_for_termination): Delete LINUX conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
3321
diff
changeset
|
357 #else /* not BSD, and not HPUX version >= 6 */ |
|
7900edb84c4f
(wait_for_termination): Delete LINUX conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
3321
diff
changeset
|
358 #if defined (UNIPLUS) |
|
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
359 if (0 > kill (pid, 0)) |
| 491 | 360 break; |
|
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
361 wait (0); |
|
3334
7900edb84c4f
(wait_for_termination): Delete LINUX conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
3321
diff
changeset
|
362 #else /* neither BSD nor UNIPLUS: random sysV */ |
|
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
363 #ifdef POSIX_SIGNALS /* would this work for LINUX as well? */ |
|
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
364 sigblock (sigmask (SIGCHLD)); |
|
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
365 if (0 > kill (pid, 0)) |
|
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
366 { |
|
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
367 sigunblock (sigmask (SIGCHLD)); |
|
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
368 break; |
|
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
369 } |
|
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
370 sigpause (SIGEMPTYMASK); |
|
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
371 #else /* not POSIX_SIGNALS */ |
|
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
372 #ifdef HAVE_SYSV_SIGPAUSE |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
373 sighold (SIGCHLD); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
374 if (0 > kill (pid, 0)) |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
375 { |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
376 sigrelse (SIGCHLD); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
377 break; |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
378 } |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
379 sigpause (SIGCHLD); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
380 #else /* not HAVE_SYSV_SIGPAUSE */ |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
381 if (0 > kill (pid, 0)) |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
382 break; |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
383 /* Using sleep instead of pause avoids timing error. |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
384 If the inferior dies just before the sleep, |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
385 we lose just one second. */ |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
386 sleep (1); |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
387 #endif /* not HAVE_SYSV_SIGPAUSE */ |
|
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
388 #endif /* not POSIX_SIGNALS */ |
|
2942
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
389 #endif /* not UNIPLUS */ |
|
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
390 #endif /* not BSD, and not HPUX version >= 6 */ |
| 491 | 391 #endif /* not VMS */ |
| 392 #else /* not subprocesses */ | |
| 393 #ifndef BSD4_1 | |
| 394 if (kill (pid, 0) < 0) | |
| 395 break; | |
| 396 wait (0); | |
| 397 #else /* BSD4_1 */ | |
| 398 int status; | |
| 399 status = wait (0); | |
| 400 if (status == pid || status == -1) | |
| 401 break; | |
| 402 #endif /* BSD4_1 */ | |
| 403 #endif /* not subprocesses */ | |
| 404 } | |
| 405 } | |
| 406 | |
| 407 #ifdef subprocesses | |
| 408 | |
| 409 /* | |
| 410 * flush any pending output | |
| 411 * (may flush input as well; it does not matter the way we use it) | |
| 412 */ | |
| 413 | |
| 414 flush_pending_output (channel) | |
| 415 int channel; | |
| 416 { | |
| 417 #ifdef HAVE_TERMIOS | |
| 418 /* If we try this, we get hit with SIGTTIN, because | |
| 419 the child's tty belongs to the child's pgrp. */ | |
| 420 #else | |
| 421 #ifdef TCFLSH | |
| 422 ioctl (channel, TCFLSH, 1); | |
| 423 #else | |
| 424 #ifdef TIOCFLUSH | |
| 425 int zero = 0; | |
| 426 /* 3rd arg should be ignored | |
| 427 but some 4.2 kernels actually want the address of an int | |
| 428 and nonzero means something different. */ | |
| 429 ioctl (channel, TIOCFLUSH, &zero); | |
| 430 #endif | |
| 431 #endif | |
| 432 #endif | |
| 433 } | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
434 |
| 491 | 435 #ifndef VMS |
| 436 /* Set up the terminal at the other end of a pseudo-terminal that | |
| 437 we will be controlling an inferior through. | |
| 438 It should not echo or do line-editing, since that is done | |
| 439 in Emacs. No padding needed for insertion into an Emacs buffer. */ | |
| 440 | |
| 441 child_setup_tty (out) | |
| 442 int out; | |
| 443 { | |
| 579 | 444 struct emacs_tty s; |
| 445 | |
| 446 EMACS_GET_TTY (out, &s); | |
| 447 | |
|
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
448 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
| 579 | 449 s.main.c_oflag |= OPOST; /* Enable output postprocessing */ |
| 450 s.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL on output */ | |
| 451 s.main.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); | |
| 452 /* No output delays */ | |
| 453 s.main.c_lflag &= ~ECHO; /* Disable echo */ | |
| 454 s.main.c_lflag |= ISIG; /* Enable signals */ | |
| 455 s.main.c_iflag &= ~IUCLC; /* Disable map of upper case to lower on | |
| 456 input */ | |
| 457 s.main.c_oflag &= ~OLCUC; /* Disable map of lower case to upper on | |
| 458 output */ | |
|
4916
83db42883f64
(child_setup_tty): Make the pty handle 8-bit characters.
Richard M. Stallman <rms@gnu.org>
parents:
4772
diff
changeset
|
459 s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */ |
| 579 | 460 #if 0 |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
461 /* Said to be unnecessary: */ |
| 579 | 462 s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */ |
| 463 s.main.c_cc[VTIME] = 0; /* wait forever for at least 1 character */ | |
| 464 #endif | |
| 465 | |
| 466 s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */ | |
| 467 s.main.c_cc[VEOF] = 04; /* insure that EOF is Control-D */ | |
| 468 s.main.c_cc[VERASE] = 0377; /* disable erase processing */ | |
| 469 s.main.c_cc[VKILL] = 0377; /* disable kill processing */ | |
| 470 | |
| 491 | 471 #ifdef HPUX |
| 579 | 472 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ |
| 491 | 473 #endif /* HPUX */ |
| 579 | 474 |
| 491 | 475 #ifdef AIX |
| 476 /* AIX enhanced edit loses NULs, so disable it */ | |
| 477 #ifndef IBMR2AIX | |
| 579 | 478 s.main.c_line = 0; |
| 479 s.main.c_iflag &= ~ASCEDIT; | |
| 491 | 480 #endif |
| 481 /* Also, PTY overloads NUL and BREAK. | |
| 482 don't ignore break, but don't signal either, so it looks like NUL. */ | |
| 579 | 483 s.main.c_iflag &= ~IGNBRK; |
| 484 s.main.c_iflag &= ~BRKINT; | |
| 485 /* QUIT and INTR work better as signals, so disable character forms */ | |
| 486 s.main.c_cc[VINTR] = 0377; | |
|
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
487 #ifdef SIGNALS_VIA_CHARACTERS |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
488 /* the QUIT and INTR character are used in process_send_signal |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
489 so set them here to something useful. */ |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
490 if (s.main.c_cc[VQUIT] == 0377) |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
491 s.main.c_cc[VQUIT] = '\\'&037; /* Control-\ */ |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
492 if (s.main.c_cc[VINTR] == 0377) |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
493 s.main.c_cc[VINTR] = 'C'&037; /* Control-C */ |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
494 #else /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
495 /* QUIT and INTR work better as signals, so disable character forms */ |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
496 s.main.c_cc[VQUIT] = 0377; |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
497 s.main.c_cc[VINTR] = 0377; |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
498 s.main.c_lflag &= ~ISIG; |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
499 #endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ |
| 579 | 500 s.main.c_cc[VEOL] = 0377; |
| 501 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ | |
| 491 | 502 #endif /* AIX */ |
| 503 | |
| 504 #else /* not HAVE_TERMIO */ | |
| 579 | 505 |
| 506 s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE | |
| 507 | CBREAK | TANDEM); | |
|
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
508 s.main.sg_flags |= LPASS8; |
| 579 | 509 s.main.sg_erase = 0377; |
| 510 s.main.sg_kill = 0377; | |
|
4916
83db42883f64
(child_setup_tty): Make the pty handle 8-bit characters.
Richard M. Stallman <rms@gnu.org>
parents:
4772
diff
changeset
|
511 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */ |
| 579 | 512 |
| 491 | 513 #endif /* not HAVE_TERMIO */ |
| 514 | |
| 579 | 515 EMACS_SET_TTY (out, &s, 0); |
| 491 | 516 |
| 517 #ifdef BSD4_1 | |
| 518 if (interrupt_input) | |
| 519 reset_sigio (); | |
| 520 #endif /* BSD4_1 */ | |
| 521 #ifdef RTU | |
| 522 { | |
| 523 int zero = 0; | |
| 524 ioctl (out, FIOASYNC, &zero); | |
| 525 } | |
| 526 #endif /* RTU */ | |
| 527 } | |
| 528 #endif /* not VMS */ | |
| 529 | |
| 530 #endif /* subprocesses */ | |
| 531 | |
| 532 /*ARGSUSED*/ | |
| 533 setpgrp_of_tty (pid) | |
| 534 int pid; | |
| 535 { | |
| 648 | 536 EMACS_SET_TTY_PGRP (input_fd, &pid); |
| 491 | 537 } |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
538 |
| 491 | 539 /* Record a signal code and the handler for it. */ |
| 540 struct save_signal | |
| 541 { | |
| 542 int code; | |
| 543 SIGTYPE (*handler) (); | |
| 544 }; | |
| 545 | |
| 546 /* Suspend the Emacs process; give terminal to its superior. */ | |
| 547 | |
| 548 sys_suspend () | |
| 549 { | |
| 550 #ifdef VMS | |
|
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
551 /* "Foster" parentage allows emacs to return to a subprocess that attached |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
552 to the current emacs as a cheaper than starting a whole new process. This |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
553 is set up by KEPTEDITOR.COM. */ |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
554 unsigned long parent_id, foster_parent_id; |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
555 char *fpid_string; |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
556 |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
557 fpid_string = getenv ("EMACS_PARENT_PID"); |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
558 if (fpid_string != NULL) |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
559 { |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
560 sscanf (fpid_string, "%x", &foster_parent_id); |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
561 if (foster_parent_id != 0) |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
562 parent_id = foster_parent_id; |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
563 else |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
564 parent_id = getppid (); |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
565 } |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
566 else |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
567 parent_id = getppid (); |
|
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
568 |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
569 xfree (fpid_string); /* On VMS, this was malloc'd */ |
|
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
570 |
| 491 | 571 if (parent_id && parent_id != 0xffffffff) |
| 572 { | |
| 573 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); | |
| 574 int status = LIB$ATTACH (&parent_id) & 1; | |
| 575 signal (SIGINT, oldsig); | |
| 576 return status; | |
| 577 } | |
| 578 else | |
| 579 { | |
| 580 struct { | |
| 581 int l; | |
| 582 char *a; | |
| 583 } d_prompt; | |
| 584 d_prompt.l = sizeof ("Emacs: "); /* Our special prompt */ | |
| 585 d_prompt.a = "Emacs: "; /* Just a reminder */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
586 LIB$SPAWN (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &d_prompt, 0); |
| 491 | 587 return 1; |
| 588 } | |
| 589 return -1; | |
| 590 #else | |
| 591 #ifdef SIGTSTP | |
| 592 | |
|
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
593 { |
|
4958
8d58e388e71b
(sys_suspend): Use EMACS_GETPGRP macro.
Richard M. Stallman <rms@gnu.org>
parents:
4952
diff
changeset
|
594 int pgrp = EMACS_GETPGRP (0); |
|
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
595 EMACS_KILLPG (pgrp, SIGTSTP); |
|
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
596 } |
| 491 | 597 |
| 598 #else /* No SIGTSTP */ | |
| 599 #ifdef USG_JOBCTRL /* If you don't know what this is don't mess with it */ | |
| 600 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */ | |
| 601 kill (getpid (), SIGQUIT); | |
| 602 | |
| 603 #else /* No SIGTSTP or USG_JOBCTRL */ | |
| 604 | |
| 605 /* On a system where suspending is not implemented, | |
| 606 instead fork a subshell and let it talk directly to the terminal | |
| 607 while we wait. */ | |
| 608 int pid = fork (); | |
| 609 struct save_signal saved_handlers[5]; | |
| 610 | |
| 611 saved_handlers[0].code = SIGINT; | |
| 612 saved_handlers[1].code = SIGQUIT; | |
| 613 saved_handlers[2].code = SIGTERM; | |
| 614 #ifdef SIGIO | |
| 615 saved_handlers[3].code = SIGIO; | |
| 616 saved_handlers[4].code = 0; | |
| 617 #else | |
| 618 saved_handlers[3].code = 0; | |
| 619 #endif | |
| 620 | |
| 621 if (pid == -1) | |
| 622 error ("Can't spawn subshell"); | |
| 623 if (pid == 0) | |
| 624 { | |
| 625 char *sh; | |
| 626 | |
| 627 sh = (char *) egetenv ("SHELL"); | |
| 628 if (sh == 0) | |
| 629 sh = "sh"; | |
| 630 /* Use our buffer's default directory for the subshell. */ | |
| 631 { | |
| 632 Lisp_Object dir; | |
| 633 unsigned char *str; | |
| 634 int len; | |
| 635 | |
| 636 /* mentioning current_buffer->buffer would mean including buffer.h, | |
| 637 which somehow wedges the hp compiler. So instead... */ | |
| 638 | |
| 639 dir = intern ("default-directory"); | |
| 640 /* Can't use NULL */ | |
| 641 if (XFASTINT (Fboundp (dir)) == XFASTINT (Qnil)) | |
| 642 goto xyzzy; | |
| 643 dir = Fsymbol_value (dir); | |
| 644 if (XTYPE (dir) != Lisp_String) | |
| 645 goto xyzzy; | |
| 646 | |
| 647 str = (unsigned char *) alloca (XSTRING (dir)->size + 2); | |
| 648 len = XSTRING (dir)->size; | |
| 649 bcopy (XSTRING (dir)->data, str, len); | |
| 650 if (str[len - 1] != '/') str[len++] = '/'; | |
| 651 str[len] = 0; | |
| 652 chdir (str); | |
| 653 } | |
| 654 xyzzy: | |
| 655 #ifdef subprocesses | |
| 656 close_process_descs (); /* Close Emacs's pipes/ptys */ | |
| 657 #endif | |
|
1203
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
658 |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
659 #ifdef PRIO_PROCESS |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
660 { |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
661 extern int emacs_priority; |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
662 |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
663 if (emacs_priority) |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
664 nice (-emacs_priority); |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
665 } |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
666 #endif |
|
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
667 |
| 491 | 668 execlp (sh, sh, 0); |
| 669 write (1, "Can't execute subshell", 22); | |
| 670 _exit (1); | |
| 671 } | |
| 672 | |
| 673 save_signal_handlers (saved_handlers); | |
|
2939
34492be68ced
* sysdep.c (sys_suspend): Set synch_process_alive, so that
Jim Blandy <jimb@redhat.com>
parents:
2913
diff
changeset
|
674 synch_process_alive = 1; |
| 491 | 675 wait_for_termination (pid); |
| 676 restore_signal_handlers (saved_handlers); | |
| 677 | |
| 678 #endif /* no USG_JOBCTRL */ | |
| 679 #endif /* no SIGTSTP */ | |
| 680 #endif /* not VMS */ | |
| 681 } | |
| 682 | |
| 683 save_signal_handlers (saved_handlers) | |
| 684 struct save_signal *saved_handlers; | |
| 685 { | |
| 686 while (saved_handlers->code) | |
| 687 { | |
| 692 | 688 saved_handlers->handler |
| 689 = (SIGTYPE (*) ()) signal (saved_handlers->code, SIG_IGN); | |
| 491 | 690 saved_handlers++; |
| 691 } | |
| 692 } | |
| 693 | |
| 694 restore_signal_handlers (saved_handlers) | |
| 695 struct save_signal *saved_handlers; | |
| 696 { | |
| 697 while (saved_handlers->code) | |
| 698 { | |
| 699 signal (saved_handlers->code, saved_handlers->handler); | |
| 700 saved_handlers++; | |
| 701 } | |
| 702 } | |
| 703 | |
| 704 #ifdef F_SETFL | |
| 705 | |
| 706 int old_fcntl_flags; | |
| 707 | |
| 708 init_sigio () | |
| 709 { | |
| 710 #ifdef FASYNC | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
711 old_fcntl_flags = fcntl (input_fd, F_GETFL, 0) & ~FASYNC; |
| 491 | 712 #endif |
| 713 request_sigio (); | |
| 714 } | |
| 715 | |
| 716 reset_sigio () | |
| 717 { | |
| 718 unrequest_sigio (); | |
| 719 } | |
| 720 | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
721 #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ |
| 491 | 722 |
| 723 request_sigio () | |
| 724 { | |
| 725 #ifdef SIGWINCH | |
| 638 | 726 sigunblock (sigmask (SIGWINCH)); |
| 491 | 727 #endif |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
728 fcntl (input_fd, F_SETFL, old_fcntl_flags | FASYNC); |
| 491 | 729 |
| 730 interrupts_deferred = 0; | |
| 731 } | |
| 732 | |
| 733 unrequest_sigio () | |
| 734 { | |
| 735 #ifdef SIGWINCH | |
| 638 | 736 sigblock (sigmask (SIGWINCH)); |
| 491 | 737 #endif |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
738 fcntl (input_fd, F_SETFL, old_fcntl_flags); |
| 491 | 739 interrupts_deferred = 1; |
| 740 } | |
| 741 | |
| 742 #else /* no FASYNC */ | |
| 743 #ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */ | |
| 744 | |
| 745 request_sigio () | |
| 746 { | |
| 747 int on = 1; | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
748 ioctl (input_fd, FIOASYNC, &on); |
| 491 | 749 interrupts_deferred = 0; |
| 750 } | |
| 751 | |
| 752 unrequest_sigio () | |
| 753 { | |
| 754 int off = 0; | |
| 755 | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
756 ioctl (input_fd, FIOASYNC, &off); |
| 491 | 757 interrupts_deferred = 1; |
| 758 } | |
| 759 | |
| 760 #else /* not FASYNC, not STRIDE */ | |
| 761 | |
| 762 request_sigio () | |
| 763 { | |
| 764 croak ("request_sigio"); | |
| 765 } | |
| 766 | |
| 767 unrequest_sigio () | |
| 768 { | |
| 769 croak ("unrequest_sigio"); | |
| 770 } | |
| 771 | |
| 772 #endif /* STRIDE */ | |
| 773 #endif /* FASYNC */ | |
| 774 #endif /* F_SETFL */ | |
| 775 | |
|
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
776 /* Saving and restoring the process group of Emacs's terminal. */ |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
777 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
778 #ifdef BSD |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
779 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
780 /* The process group of which Emacs was a member when it initially |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
781 started. |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
782 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
783 If Emacs was in its own process group (i.e. inherited_pgroup == |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
784 getpid ()), then we know we're running under a shell with job |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
785 control (Emacs would never be run as part of a pipeline). |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
786 Everything is fine. |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
787 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
788 If Emacs was not in its own process group, then we know we're |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
789 running under a shell (or a caller) that doesn't know how to |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
790 separate itself from Emacs (like sh). Emacs must be in its own |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
791 process group in order to receive SIGIO correctly. In this |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
792 situation, we put ourselves in our own pgroup, forcibly set the |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
793 tty's pgroup to our pgroup, and make sure to restore and reinstate |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
794 the tty's pgroup just like any other terminal setting. If |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
795 inherited_group was not the tty's pgroup, then we'll get a |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
796 SIGTTmumble when we try to change the tty's pgroup, and a CONT if |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
797 it goes foreground in the future, which is what should happen. */ |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
798 int inherited_pgroup; |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
799 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
800 /* Split off the foreground process group to Emacs alone. |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
801 When we are in the foreground, but not started in our own process |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
802 group, redirect the TTY to point to our own process group. We need |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
803 to be in our own process group to receive SIGIO properly. */ |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
804 narrow_foreground_group () |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
805 { |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
806 int me = getpid (); |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
807 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
808 setpgrp (0, inherited_pgroup); |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
809 if (inherited_pgroup != me) |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
810 EMACS_SET_TTY_PGRP (input_fd, &me); |
|
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
811 setpgrp (0, me); |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
812 } |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
813 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
814 /* Set the tty to our original foreground group. */ |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
815 widen_foreground_group () |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
816 { |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
817 if (inherited_pgroup != getpid ()) |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
818 EMACS_SET_TTY_PGRP (input_fd, &inherited_pgroup); |
|
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
819 setpgrp (0, inherited_pgroup); |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
820 } |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
821 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
822 #endif |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
823 |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
824 /* Getting and setting emacs_tty structures. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
825 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
826 /* Set *TC to the parameters associated with the terminal FD. |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
827 Return zero if all's well, or -1 if we ran into an error we |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
828 couldn't deal with. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
829 int |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
830 emacs_get_tty (fd, settings) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
831 int fd; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
832 struct emacs_tty *settings; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
833 { |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
834 /* Retrieve the primary parameters - baud rate, character size, etcetera. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
835 #ifdef HAVE_TCATTR |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
836 /* We have those nifty POSIX tcmumbleattr functions. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
837 if (tcgetattr (fd, &settings->main) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
838 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
839 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
840 #else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
841 #ifdef HAVE_TERMIO |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
842 /* The SYSV-style interface? */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
843 if (ioctl (fd, TCGETA, &settings->main) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
844 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
845 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
846 #else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
847 #ifdef VMS |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
848 /* Vehemently Monstrous System? :-) */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
849 if (! (SYS$QIOW (0, fd, IO$_SENSEMODE, settings, 0, 0, |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
850 &settings->main.class, 12, 0, 0, 0, 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
851 & 1)) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
852 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
853 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
854 #else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
855 /* I give up - I hope you have the BSD ioctls. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
856 if (ioctl (fd, TIOCGETP, &settings->main) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
857 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
858 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
859 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
860 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
861 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
862 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
863 /* Suivant - Do we have to get struct ltchars data? */ |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
864 #ifdef HAVE_LTCHARS |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
865 if (ioctl (fd, TIOCGLTC, &settings->ltchars) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
866 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
867 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
868 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
869 /* How about a struct tchars and a wordful of lmode bits? */ |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
870 #ifdef HAVE_TCHARS |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
871 if (ioctl (fd, TIOCGETC, &settings->tchars) < 0 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
872 || ioctl (fd, TIOCLGET, &settings->lmode) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
873 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
874 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
875 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
876 /* We have survived the tempest. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
877 return 0; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
878 } |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
879 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
880 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
881 /* Set the parameters of the tty on FD according to the contents of |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
882 *SETTINGS. If WAITP is non-zero, we wait for all queued output to |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
883 be written before making the change; otherwise, we forget any |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
884 queued input and make the change immediately. |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
885 Return 0 if all went well, and -1 if anything failed. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
886 int |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
887 emacs_set_tty (fd, settings, waitp) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
888 int fd; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
889 struct emacs_tty *settings; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
890 int waitp; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
891 { |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
892 /* Set the primary parameters - baud rate, character size, etcetera. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
893 #ifdef HAVE_TCATTR |
|
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
894 int i; |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
895 /* We have those nifty POSIX tcmumbleattr functions. |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
896 William J. Smith <wjs@wiis.wang.com> writes: |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
897 "POSIX 1003.1 defines tcsetattr() to return success if it was |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
898 able to perform any of the requested actions, even if some |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
899 of the requested actions could not be performed. |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
900 We must read settings back to ensure tty setup properly. |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
901 AIX requires this to keep tty from hanging occasionally." */ |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
902 /* This make sure that we don't loop indefinitely in here. */ |
|
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
903 for (i = 0 ; i < 10 ; i++) |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
904 if (tcsetattr (fd, waitp ? TCSAFLUSH : TCSADRAIN, &settings->main) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
905 { |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
906 if (errno == EINTR) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
907 continue; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
908 else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
909 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
910 } |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
911 else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
912 { |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
913 struct termios new; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
914 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
915 /* Get the current settings, and see if they're what we asked for. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
916 tcgetattr (fd, &new); |
|
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
917 /* We cannot use memcmp on the whole structure here because under |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
918 * aix386 the termios structure has some reserved field that may |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
919 * not be filled in. |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
920 */ |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
921 if ( new.c_iflag == settings->main.c_iflag |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
922 && new.c_oflag == settings->main.c_oflag |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
923 && new.c_cflag == settings->main.c_cflag |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
924 && new.c_lflag == settings->main.c_lflag |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
925 && memcmp(new.c_cc, settings->main.c_cc, NCCS) == 0) |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
926 break; |
|
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
927 else |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
928 continue; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
929 } |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
930 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
931 #else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
932 #ifdef HAVE_TERMIO |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
933 /* The SYSV-style interface? */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
934 if (ioctl (fd, waitp ? TCSETAW : TCSETAF, &settings->main) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
935 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
936 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
937 #else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
938 #ifdef VMS |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
939 /* Vehemently Monstrous System? :-) */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
940 if (! (SYS$QIOW (0, fd, IO$_SETMODE, &input_iosb, 0, 0, |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
941 &settings->main.class, 12, 0, 0, 0, 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
942 & 1)) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
943 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
944 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
945 #else |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
946 /* I give up - I hope you have the BSD ioctls. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
947 if (ioctl (fd, (waitp) ? TIOCSETP : TIOCSETN, &settings->main) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
948 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
949 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
950 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
951 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
952 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
953 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
954 /* Suivant - Do we have to get struct ltchars data? */ |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
955 #ifdef HAVE_LTCHARS |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
956 if (ioctl (fd, TIOCSLTC, &settings->ltchars) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
957 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
958 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
959 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
960 /* How about a struct tchars and a wordful of lmode bits? */ |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
961 #ifdef HAVE_TCHARS |
|
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
962 if (ioctl (fd, TIOCSETC, &settings->tchars) < 0 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
963 || ioctl (fd, TIOCLSET, &settings->lmode) < 0) |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
964 return -1; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
965 #endif |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
966 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
967 /* We have survived the tempest. */ |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
968 return 0; |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
969 } |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
970 |
|
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
971 |
| 579 | 972 /* The initial tty mode bits */ |
| 973 struct emacs_tty old_tty; | |
| 491 | 974 |
| 975 int term_initted; /* 1 if outer tty status has been recorded */ | |
| 976 | |
| 579 | 977 #ifdef BSD4_1 |
| 978 /* BSD 4.1 needs to keep track of the lmode bits in order to start | |
| 979 sigio. */ | |
| 980 int lmode; | |
| 981 #endif | |
| 982 | |
|
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
983 #ifndef F_SETOWN_BUG |
| 491 | 984 #ifdef F_SETOWN |
| 985 int old_fcntl_owner; | |
| 986 #endif /* F_SETOWN */ | |
|
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
987 #endif /* F_SETOWN_BUG */ |
| 491 | 988 |
| 989 /* This may also be defined in stdio, | |
| 990 but if so, this does no harm, | |
| 991 and using the same name avoids wasting the other one's space. */ | |
| 992 | |
| 993 #if defined (USG) || defined (DGUX) | |
| 994 unsigned char _sobuf[BUFSIZ+8]; | |
| 995 #else | |
| 996 char _sobuf[BUFSIZ]; | |
| 997 #endif | |
| 998 | |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
999 #ifdef HAVE_LTCHARS |
| 491 | 1000 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; |
| 1001 #endif | |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1002 #ifdef HAVE_TCHARS |
| 491 | 1003 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; |
| 1004 #endif | |
| 1005 | |
| 1006 init_sys_modes () | |
| 1007 { | |
| 579 | 1008 struct emacs_tty tty; |
| 1009 | |
| 491 | 1010 #ifdef VMS |
| 1011 #if 0 | |
| 1012 static int oob_chars[2] = {0, 1 << 7}; /* catch C-g's */ | |
| 1013 extern int (*interrupt_signal) (); | |
| 1014 #endif | |
| 1015 #endif | |
| 1016 | |
| 1017 if (noninteractive) | |
| 1018 return; | |
| 1019 | |
| 1020 #ifdef VMS | |
| 1021 if (!input_ef) | |
| 1022 input_ef = get_kbd_event_flag (); | |
| 1023 /* LIB$GET_EF (&input_ef); */ | |
| 1024 SYS$CLREF (input_ef); | |
| 1025 waiting_for_ast = 0; | |
| 1026 if (!timer_ef) | |
| 1027 timer_ef = get_timer_event_flag (); | |
| 1028 /* LIB$GET_EF (&timer_ef); */ | |
| 1029 SYS$CLREF (timer_ef); | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1030 #if 0 |
| 491 | 1031 if (!process_ef) |
| 1032 { | |
| 1033 LIB$GET_EF (&process_ef); | |
| 1034 SYS$CLREF (process_ef); | |
| 1035 } | |
| 1036 if (input_ef / 32 != process_ef / 32) | |
| 1037 croak ("Input and process event flags in different clusters."); | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1038 #endif |
| 491 | 1039 if (input_ef / 32 != timer_ef / 32) |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1040 croak ("Input and timer event flags in different clusters."); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1041 #if 0 |
| 491 | 1042 input_eflist = ((unsigned) 1 << (input_ef % 32)) | |
| 1043 ((unsigned) 1 << (process_ef % 32)); | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1044 #endif |
| 491 | 1045 timer_eflist = ((unsigned) 1 << (input_ef % 32)) | |
| 1046 ((unsigned) 1 << (timer_ef % 32)); | |
| 1047 #ifndef VMS4_4 | |
| 1048 sys_access_reinit (); | |
| 1049 #endif | |
| 1050 #endif /* not VMS */ | |
| 579 | 1051 |
|
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1052 #ifdef BSD |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1053 if (! read_socket_hook && EQ (Vwindow_system, Qnil)) |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1054 narrow_foreground_group (); |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1055 #endif |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1056 |
| 579 | 1057 EMACS_GET_TTY (input_fd, &old_tty); |
| 1058 | |
| 491 | 1059 if (!read_socket_hook && EQ (Vwindow_system, Qnil)) |
| 1060 { | |
| 579 | 1061 tty = old_tty; |
| 491 | 1062 |
|
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
1063 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
| 579 | 1064 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ |
| 1065 tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ | |
| 491 | 1066 #ifdef ISTRIP |
| 579 | 1067 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ |
| 491 | 1068 #endif |
| 579 | 1069 tty.main.c_lflag &= ~ECHO; /* Disable echo */ |
| 1070 tty.main.c_lflag &= ~ICANON; /* Disable erase/kill processing */ | |
|
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1071 #ifdef IEXTEN |
|
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1072 tty.main.c_iflag &= ~IEXTEN; /* Disable other editing characters. */ |
|
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1073 #endif |
| 579 | 1074 tty.main.c_lflag |= ISIG; /* Enable signals */ |
| 491 | 1075 if (flow_control) |
| 1076 { | |
| 579 | 1077 tty.main.c_iflag |= IXON; /* Enable start/stop output control */ |
| 491 | 1078 #ifdef IXANY |
| 579 | 1079 tty.main.c_iflag &= ~IXANY; |
| 491 | 1080 #endif /* IXANY */ |
| 1081 } | |
| 1082 else | |
| 579 | 1083 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ |
| 1084 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL | |
| 1085 on output */ | |
| 1086 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ | |
| 491 | 1087 #ifdef CS8 |
| 1088 if (meta_key) | |
| 1089 { | |
| 579 | 1090 tty.main.c_cflag |= CS8; /* allow 8th bit on input */ |
| 1091 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ | |
| 491 | 1092 } |
| 1093 #endif | |
| 579 | 1094 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ |
| 491 | 1095 /* Set up C-g for both SIGQUIT and SIGINT. |
| 1096 We don't know which we will get, but we handle both alike | |
| 1097 so which one it really gives us does not matter. */ | |
| 579 | 1098 tty.main.c_cc[VQUIT] = quit_char; |
| 1099 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ | |
| 1100 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */ | |
| 491 | 1101 #ifdef VSWTCH |
|
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1102 tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use |
| 579 | 1103 of C-z */ |
| 491 | 1104 #endif /* VSWTCH */ |
| 1105 #if defined (mips) || defined (HAVE_TCATTR) | |
| 1106 #ifdef VSUSP | |
|
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1107 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ |
| 491 | 1108 #endif /* VSUSP */ |
| 1109 #ifdef V_DSUSP | |
|
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1110 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ |
| 491 | 1111 #endif /* V_DSUSP */ |
|
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1112 #ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */ |
|
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1113 tty.main.c_cc[VDSUSP] = CDISABLE; |
|
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1114 #endif /* VDSUSP */ |
|
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1115 #ifdef VLNEXT |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1116 tty.main.c_cc[VLNEXT] = CDISABLE; |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1117 #endif /* VLNEXT */ |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1118 #ifdef VREPRINT |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1119 tty.main.c_cc[VREPRINT] = CDISABLE; |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1120 #endif /* VREPRINT */ |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1121 #ifdef VWERASE |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1122 tty.main.c_cc[VWERASE] = CDISABLE; |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1123 #endif /* VWERASE */ |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1124 #ifdef VDISCARD |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1125 tty.main.c_cc[VDISCARD] = CDISABLE; |
|
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1126 #endif /* VDISCARD */ |
| 491 | 1127 #endif /* mips or HAVE_TCATTR */ |
| 1128 #ifdef AIX | |
| 1129 #ifndef IBMR2AIX | |
| 1130 /* AIX enhanced edit loses NULs, so disable it */ | |
| 579 | 1131 tty.main.c_line = 0; |
| 1132 tty.main.c_iflag &= ~ASCEDIT; | |
| 491 | 1133 #else |
| 579 | 1134 tty.main.c_cc[VSTRT] = 255; |
| 1135 tty.main.c_cc[VSTOP] = 255; | |
| 1136 tty.main.c_cc[VSUSP] = 255; | |
| 1137 tty.main.c_cc[VDSUSP] = 255; | |
| 491 | 1138 #endif /* IBMR2AIX */ |
| 1139 /* Also, PTY overloads NUL and BREAK. | |
| 1140 don't ignore break, but don't signal either, so it looks like NUL. | |
| 1141 This really serves a purpose only if running in an XTERM window | |
| 1142 or via TELNET or the like, but does no harm elsewhere. */ | |
| 579 | 1143 tty.main.c_iflag &= ~IGNBRK; |
| 1144 tty.main.c_iflag &= ~BRKINT; | |
| 491 | 1145 #endif |
| 1146 #else /* if not HAVE_TERMIO */ | |
| 1147 #ifdef VMS | |
| 579 | 1148 tty.main.tt_char |= TT$M_NOECHO; |
| 491 | 1149 if (meta_key) |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
1150 tty.main.tt_char |= TT$M_EIGHTBIT; |
| 491 | 1151 if (flow_control) |
| 579 | 1152 tty.main.tt_char |= TT$M_TTSYNC; |
| 491 | 1153 else |
| 579 | 1154 tty.main.tt_char &= ~TT$M_TTSYNC; |
| 1155 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; | |
| 491 | 1156 #else /* not VMS (BSD, that is) */ |
| 579 | 1157 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); |
| 491 | 1158 if (meta_key) |
| 579 | 1159 tty.main.sg_flags |= ANYP; |
| 1160 tty.main.sg_flags |= interrupt_input ? RAW : CBREAK; | |
| 491 | 1161 #endif /* not VMS (BSD, that is) */ |
| 1162 #endif /* not HAVE_TERMIO */ | |
| 1163 | |
| 579 | 1164 /* If going to use CBREAK mode, we must request C-g to interrupt |
| 1165 and turn off start and stop chars, etc. If not going to use | |
| 1166 CBREAK mode, do this anyway so as to turn off local flow | |
| 1167 control for user coming over network on 4.2; in this case, | |
| 1168 only t_stopc and t_startc really matter. */ | |
| 1169 #ifndef HAVE_TERMIO | |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1170 #ifdef HAVE_TCHARS |
| 579 | 1171 /* Note: if not using CBREAK mode, it makes no difference how we |
| 1172 set this */ | |
| 1173 tty.tchars = new_tchars; | |
| 1174 tty.tchars.t_intrc = quit_char; | |
| 1175 if (flow_control) | |
| 1176 { | |
| 1177 tty.tchars.t_startc = '\021'; | |
| 1178 tty.tchars.t_stopc = '\023'; | |
| 1179 } | |
| 1180 | |
| 1181 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | old_tty.lmode; | |
|
3759
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1182 #ifdef ultrix |
|
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1183 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt |
|
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1184 anything, and leaving it in breaks the meta key. Go figure. */ |
|
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1185 tty.lmode &= ~LLITOUT; |
|
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1186 #endif |
| 579 | 1187 |
| 1188 #ifdef BSD4_1 | |
| 1189 lmode = tty.lmode; | |
| 1190 #endif | |
| 1191 | |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1192 #endif /* HAVE_TCHARS */ |
| 579 | 1193 #endif /* not HAVE_TERMIO */ |
| 1194 | |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1195 #ifdef HAVE_LTCHARS |
| 579 | 1196 tty.ltchars = new_ltchars; |
|
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1197 #endif /* HAVE_LTCHARS */ |
| 579 | 1198 |
| 1199 EMACS_SET_TTY (input_fd, &tty, 0); | |
| 491 | 1200 |
| 1201 /* This code added to insure that, if flow-control is not to be used, | |
| 766 | 1202 we have an unlocked terminal at the start. */ |
| 579 | 1203 |
| 491 | 1204 #ifdef TCXONC |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1205 if (!flow_control) ioctl (input_fd, TCXONC, 1); |
| 491 | 1206 #endif |
| 1207 #ifndef APOLLO | |
| 1208 #ifdef TIOCSTART | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1209 if (!flow_control) ioctl (input_fd, TIOCSTART, 0); |
| 491 | 1210 #endif |
| 1211 #endif | |
| 1212 | |
| 1213 #ifdef AIX | |
| 1214 hft_init (); | |
| 1215 #ifdef IBMR2AIX | |
| 1216 { | |
| 1217 /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it | |
| 1218 to be only LF. This is the way that is done. */ | |
| 1219 struct termio tty; | |
| 1220 | |
| 1221 if (ioctl (1, HFTGETID, &tty) != -1) | |
| 1222 write (1, "\033[20l", 5); | |
| 1223 } | |
| 1224 #endif | |
| 1225 #endif | |
| 1226 | |
| 1227 #ifdef VMS | |
| 1228 /* Appears to do nothing when in PASTHRU mode. | |
| 579 | 1229 SYS$QIOW (0, input_fd, IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, |
| 491 | 1230 interrupt_signal, oob_chars, 0, 0, 0, 0); |
| 1231 */ | |
| 1232 queue_kbd_input (0); | |
| 1233 #endif /* VMS */ | |
| 1234 } | |
| 1235 | |
| 1236 #ifdef F_SETFL | |
|
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1237 #ifndef F_SETOWN_BUG |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1238 #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ |
| 491 | 1239 if (interrupt_input) |
| 1240 { | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1241 old_fcntl_owner = fcntl (input_fd, F_GETOWN, 0); |
|
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1242 fcntl (input_fd, F_SETOWN, getpid ()); |
| 491 | 1243 init_sigio (); |
| 1244 } | |
| 1245 #endif /* F_GETOWN */ | |
|
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1246 #endif /* F_SETOWN_BUG */ |
| 491 | 1247 #endif /* F_SETFL */ |
| 1248 | |
| 1249 #ifdef BSD4_1 | |
| 1250 if (interrupt_input) | |
| 1251 init_sigio (); | |
| 1252 #endif | |
| 1253 | |
| 1254 #ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ | |
| 1255 #undef _IOFBF | |
| 1256 #endif | |
| 1257 #ifdef _IOFBF | |
| 1258 /* This symbol is defined on recent USG systems. | |
| 1259 Someone says without this call USG won't really buffer the file | |
| 1260 even with a call to setbuf. */ | |
| 1261 setvbuf (stdout, _sobuf, _IOFBF, sizeof _sobuf); | |
| 1262 #else | |
| 1263 setbuf (stdout, _sobuf); | |
| 1264 #endif | |
| 1265 set_terminal_modes (); | |
| 1266 if (term_initted && no_redraw_on_reenter) | |
| 1267 { | |
| 1268 if (display_completed) | |
| 1269 direct_output_forward_char (0); | |
| 1270 } | |
| 1271 else | |
| 1272 { | |
| 766 | 1273 frame_garbaged = 1; |
| 1274 #ifdef MULTI_FRAME | |
| 1275 if (FRAMEP (Vterminal_frame)) | |
| 1276 FRAME_GARBAGED_P (XFRAME (Vterminal_frame)) = 1; | |
| 491 | 1277 #endif |
| 1278 } | |
| 579 | 1279 |
| 491 | 1280 term_initted = 1; |
| 1281 } | |
| 1282 | |
| 1283 /* Return nonzero if safe to use tabs in output. | |
| 1284 At the time this is called, init_sys_modes has not been done yet. */ | |
| 1285 | |
| 1286 tabs_safe_p () | |
| 1287 { | |
| 579 | 1288 struct emacs_tty tty; |
| 1289 | |
| 1290 EMACS_GET_TTY (input_fd, &tty); | |
| 1291 return EMACS_TTY_TABS_OK (&tty); | |
| 491 | 1292 } |
| 1293 | |
| 1294 /* Get terminal size from system. | |
| 1295 Store number of lines into *heightp and width into *widthp. | |
| 1296 If zero or a negative number is stored, the value is not valid. */ | |
| 1297 | |
| 766 | 1298 get_frame_size (widthp, heightp) |
| 491 | 1299 int *widthp, *heightp; |
| 1300 { | |
| 579 | 1301 |
| 1302 #ifdef TIOCGWINSZ | |
| 1303 | |
| 1304 /* BSD-style. */ | |
| 1305 struct winsize size; | |
| 1306 | |
| 1307 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) | |
| 1308 *widthp = *heightp = 0; | |
| 1309 else | |
| 1310 { | |
| 1311 *widthp = size.ws_col; | |
| 1312 *heightp = size.ws_row; | |
| 1313 } | |
| 1314 | |
| 1315 #else | |
| 491 | 1316 #ifdef TIOCGSIZE |
| 579 | 1317 |
| 1318 /* SunOS - style. */ | |
| 1319 struct ttysize size; | |
| 1320 | |
| 1321 if (ioctl (input_fd, TIOCGSIZE, &size) == -1) | |
| 1322 *widthp = *heightp = 0; | |
| 1323 else | |
| 1324 { | |
| 1325 *widthp = size.ts_cols; | |
| 1326 *heightp = size.ts_lines; | |
| 1327 } | |
| 1328 | |
| 1329 #else | |
| 491 | 1330 #ifdef VMS |
| 579 | 1331 |
| 1332 struct sensemode tty; | |
| 1333 | |
| 1334 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, | |
| 491 | 1335 &tty.class, 12, 0, 0, 0, 0); |
| 1336 *widthp = tty.scr_wid; | |
| 1337 *heightp = tty.scr_len; | |
| 579 | 1338 |
| 491 | 1339 #else /* system doesn't know size */ |
| 579 | 1340 |
| 491 | 1341 *widthp = 0; |
| 1342 *heightp = 0; | |
| 579 | 1343 |
| 1344 #endif /* not VMS */ | |
| 1345 #endif /* not SunOS-style */ | |
| 1346 #endif /* not BSD-style */ | |
| 491 | 1347 } |
| 579 | 1348 |
| 491 | 1349 |
| 579 | 1350 /* Prepare the terminal for exiting Emacs; move the cursor to the |
| 766 | 1351 bottom of the frame, turn off interrupt-driven I/O, etc. */ |
| 491 | 1352 reset_sys_modes () |
| 1353 { | |
| 1354 if (noninteractive) | |
| 1355 { | |
| 1356 fflush (stdout); | |
| 1357 return; | |
| 1358 } | |
| 1359 if (!term_initted) | |
| 1360 return; | |
| 1361 if (read_socket_hook || !EQ (Vwindow_system, Qnil)) | |
| 1362 return; | |
| 766 | 1363 cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0); |
| 1364 clear_end_of_line (FRAME_WIDTH (selected_frame)); | |
| 491 | 1365 /* clear_end_of_line may move the cursor */ |
| 766 | 1366 cursor_to (FRAME_HEIGHT (selected_frame) - 1, 0); |
| 491 | 1367 #ifdef IBMR2AIX |
| 1368 { | |
| 1369 /* HFT devices normally use ^J as a LF/CR. We forced it to | |
| 1370 do the LF only. Now, we need to reset it. */ | |
| 1371 struct termio tty; | |
| 1372 | |
| 1373 if (ioctl (1, HFTGETID, &tty) != -1) | |
| 1374 write (1, "\033[20h", 5); | |
| 1375 } | |
| 1376 #endif | |
| 1377 | |
| 1378 reset_terminal_modes (); | |
| 1379 fflush (stdout); | |
| 1380 #ifdef BSD | |
| 1381 #ifndef BSD4_1 | |
| 1382 /* Avoid possible loss of output when changing terminal modes. */ | |
| 1383 fsync (fileno (stdout)); | |
| 1384 #endif | |
| 1385 #endif | |
| 579 | 1386 |
| 491 | 1387 #ifdef F_SETFL |
|
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1388 #ifndef F_SETOWN_BUG |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1389 #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ |
| 491 | 1390 if (interrupt_input) |
| 1391 { | |
| 1392 reset_sigio (); | |
|
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
1393 fcntl (input_fd, F_SETOWN, old_fcntl_owner); |
| 491 | 1394 } |
| 1395 #endif /* F_SETOWN */ | |
|
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1396 #endif /* F_SETOWN_BUG */ |
| 491 | 1397 #endif /* F_SETFL */ |
| 1398 #ifdef BSD4_1 | |
| 1399 if (interrupt_input) | |
| 1400 reset_sigio (); | |
| 1401 #endif /* BSD4_1 */ | |
| 579 | 1402 |
|
2873
f1cd54cf1b67
* sysdep.c (reset_sys_modes): Test the return value of
Jim Blandy <jimb@redhat.com>
parents:
2656
diff
changeset
|
1403 while (EMACS_SET_TTY (input_fd, &old_tty, 0) < 0 && errno == EINTR) |
| 579 | 1404 ; |
| 491 | 1405 |
| 1406 #ifdef AIX | |
| 1407 hft_reset (); | |
| 1408 #endif | |
|
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1409 |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1410 #ifdef BSD |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1411 widen_foreground_group (); |
|
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1412 #endif |
| 491 | 1413 } |
| 1414 | |
| 1415 #ifdef HAVE_PTYS | |
| 1416 | |
| 1417 /* Set up the proper status flags for use of a pty. */ | |
| 1418 | |
| 1419 setup_pty (fd) | |
| 1420 int fd; | |
| 1421 { | |
| 1422 /* I'm told that TOICREMOTE does not mean control chars | |
| 1423 "can't be sent" but rather that they don't have | |
| 1424 input-editing or signaling effects. | |
| 1425 That should be good, because we have other ways | |
| 1426 to do those things in Emacs. | |
| 1427 However, telnet mode seems not to work on 4.2. | |
| 1428 So TIOCREMOTE is turned off now. */ | |
| 1429 | |
| 1430 /* Under hp-ux, if TIOCREMOTE is turned on, some calls | |
| 1431 will hang. In particular, the "timeout" feature (which | |
| 1432 causes a read to return if there is no data available) | |
| 1433 does this. Also it is known that telnet mode will hang | |
| 1434 in such a way that Emacs must be stopped (perhaps this | |
| 1435 is the same problem). | |
| 1436 | |
| 1437 If TIOCREMOTE is turned off, then there is a bug in | |
| 1438 hp-ux which sometimes loses data. Apparently the | |
| 1439 code which blocks the master process when the internal | |
| 1440 buffer fills up does not work. Other than this, | |
| 1441 though, everything else seems to work fine. | |
| 1442 | |
| 1443 Since the latter lossage is more benign, we may as well | |
| 1444 lose that way. -- cph */ | |
| 1445 #ifdef FIONBIO | |
| 1446 #ifdef SYSV_PTYS | |
| 1447 { | |
| 1448 int on = 1; | |
| 1449 ioctl (fd, FIONBIO, &on); | |
| 1450 } | |
| 1451 #endif | |
| 1452 #endif | |
| 1453 #ifdef IBMRTAIX | |
| 1454 /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */ | |
| 1455 /* ignore SIGHUP once we've started a child on a pty. Note that this may */ | |
| 1456 /* cause EMACS not to die when it should, i.e., when its own controlling */ | |
| 1457 /* tty goes away. I've complained to the AIX developers, and they may */ | |
| 1458 /* change this behavior, but I'm not going to hold my breath. */ | |
| 1459 signal (SIGHUP, SIG_IGN); | |
| 1460 #endif | |
| 1461 } | |
| 1462 #endif /* HAVE_PTYS */ | |
| 1463 | |
| 1464 #ifdef VMS | |
| 1465 | |
| 1466 /* Assigning an input channel is done at the start of Emacs execution. | |
| 1467 This is called each time Emacs is resumed, also, but does nothing | |
| 1468 because input_chain is no longer zero. */ | |
| 1469 | |
| 1470 init_vms_input () | |
| 1471 { | |
| 1472 int status; | |
| 1473 | |
| 579 | 1474 if (input_fd == 0) |
| 491 | 1475 { |
| 579 | 1476 status = SYS$ASSIGN (&input_dsc, &input_fd, 0, 0); |
| 491 | 1477 if (! (status & 1)) |
| 1478 LIB$STOP (status); | |
| 1479 } | |
| 1480 } | |
| 1481 | |
| 1482 /* Deassigning the input channel is done before exiting. */ | |
| 1483 | |
| 1484 stop_vms_input () | |
| 1485 { | |
| 579 | 1486 return SYS$DASSGN (input_fd); |
| 491 | 1487 } |
| 1488 | |
| 1489 short input_buffer; | |
| 1490 | |
| 1491 /* Request reading one character into the keyboard buffer. | |
| 1492 This is done as soon as the buffer becomes empty. */ | |
| 1493 | |
| 1494 queue_kbd_input () | |
| 1495 { | |
| 1496 int status; | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1497 extern kbd_input_ast (); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1498 |
| 491 | 1499 waiting_for_ast = 0; |
| 1500 stop_input = 0; | |
| 579 | 1501 status = SYS$QIO (0, input_fd, IO$_READVBLK, |
| 491 | 1502 &input_iosb, kbd_input_ast, 1, |
| 1503 &input_buffer, 1, 0, terminator_mask, 0, 0); | |
| 1504 } | |
| 1505 | |
| 1506 int input_count; | |
| 1507 | |
| 1508 /* Ast routine that is called when keyboard input comes in | |
| 1509 in accord with the SYS$QIO above. */ | |
| 1510 | |
| 1511 kbd_input_ast () | |
| 1512 { | |
| 1513 register int c = -1; | |
| 1514 int old_errno = errno; | |
| 648 | 1515 extern EMACS_TIME *input_available_clear_time; |
| 491 | 1516 |
| 1517 if (waiting_for_ast) | |
| 1518 SYS$SETEF (input_ef); | |
| 1519 waiting_for_ast = 0; | |
| 1520 input_count++; | |
| 1521 #ifdef ASTDEBUG | |
| 1522 if (input_count == 25) | |
| 1523 exit (1); | |
| 1524 printf ("Ast # %d,", input_count); | |
| 1525 printf (" iosb = %x, %x, %x, %x", | |
| 1526 input_iosb.offset, input_iosb.status, input_iosb.termlen, | |
| 1527 input_iosb.term); | |
| 1528 #endif | |
| 1529 if (input_iosb.offset) | |
| 1530 { | |
| 1531 c = input_buffer; | |
| 1532 #ifdef ASTDEBUG | |
| 1533 printf (", char = 0%o", c); | |
| 1534 #endif | |
| 1535 } | |
| 1536 #ifdef ASTDEBUG | |
| 1537 printf ("\n"); | |
| 1538 fflush (stdout); | |
| 1539 sleep (1); | |
| 1540 #endif | |
| 1541 if (! stop_input) | |
| 1542 queue_kbd_input (); | |
| 1543 if (c >= 0) | |
| 1544 { | |
| 1545 struct input_event e; | |
| 1546 e.kind = ascii_keystroke; | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1547 XSET (e.code, Lisp_Int, c); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1548 #ifdef MULTI_FRAME |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1549 XSET(e.frame_or_window, Lisp_Frame, selected_frame); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1550 #else |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1551 e.frame_or_window = Qnil; |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1552 #endif |
| 491 | 1553 kbd_buffer_store_event (&e); |
| 1554 } | |
| 648 | 1555 if (input_available_clear_time) |
| 1556 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | |
| 491 | 1557 errno = old_errno; |
| 1558 } | |
| 1559 | |
| 1560 /* Wait until there is something in kbd_buffer. */ | |
| 1561 | |
| 1562 wait_for_kbd_input () | |
| 1563 { | |
| 1564 extern int have_process_input, process_exited; | |
| 1565 | |
| 1566 /* If already something, avoid doing system calls. */ | |
| 1567 if (detect_input_pending ()) | |
| 1568 { | |
| 1569 return; | |
| 1570 } | |
| 1571 /* Clear a flag, and tell ast routine above to set it. */ | |
| 1572 SYS$CLREF (input_ef); | |
| 1573 waiting_for_ast = 1; | |
| 1574 /* Check for timing error: ast happened while we were doing that. */ | |
| 1575 if (!detect_input_pending ()) | |
| 1576 { | |
| 1577 /* No timing error: wait for flag to be set. */ | |
| 1578 set_waiting_for_input (0); | |
| 1579 SYS$WFLOR (input_ef, input_eflist); | |
| 1580 clear_waiting_for_input (0); | |
| 1581 if (!detect_input_pending ()) | |
| 1582 /* Check for subprocess input availability */ | |
| 1583 { | |
| 1584 int dsp = have_process_input || process_exited; | |
| 1585 | |
| 1586 SYS$CLREF (process_ef); | |
| 1587 if (have_process_input) | |
| 1588 process_command_input (); | |
| 1589 if (process_exited) | |
| 1590 process_exit (); | |
| 1591 if (dsp) | |
| 1592 { | |
| 1593 update_mode_lines++; | |
| 1594 redisplay_preserve_echo_area (); | |
| 1595 } | |
| 1596 } | |
| 1597 } | |
| 1598 waiting_for_ast = 0; | |
| 1599 } | |
| 1600 | |
| 1601 /* Get rid of any pending QIO, when we are about to suspend | |
| 1602 or when we want to throw away pending input. | |
| 1603 We wait for a positive sign that the AST routine has run | |
| 1604 and therefore there is no I/O request queued when we return. | |
| 1605 SYS$SETAST is used to avoid a timing error. */ | |
| 1606 | |
| 1607 end_kbd_input () | |
| 1608 { | |
| 1609 #ifdef ASTDEBUG | |
| 1610 printf ("At end_kbd_input.\n"); | |
| 1611 fflush (stdout); | |
| 1612 sleep (1); | |
| 1613 #endif | |
| 1614 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ | |
| 1615 { | |
| 579 | 1616 SYS$CANCEL (input_fd); |
| 491 | 1617 return; |
| 1618 } | |
| 1619 | |
| 1620 SYS$SETAST (0); | |
| 1621 /* Clear a flag, and tell ast routine above to set it. */ | |
| 1622 SYS$CLREF (input_ef); | |
| 1623 waiting_for_ast = 1; | |
| 1624 stop_input = 1; | |
| 579 | 1625 SYS$CANCEL (input_fd); |
| 491 | 1626 SYS$SETAST (1); |
| 1627 SYS$WAITFR (input_ef); | |
| 1628 waiting_for_ast = 0; | |
| 1629 } | |
| 1630 | |
| 1631 /* Wait for either input available or time interval expiry. */ | |
| 1632 | |
| 1633 input_wait_timeout (timeval) | |
| 1634 int timeval; /* Time to wait, in seconds */ | |
| 1635 { | |
| 1636 int time [2]; | |
| 1637 static int zero = 0; | |
| 1638 static int large = -10000000; | |
| 1639 | |
| 1640 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
| 1641 | |
| 1642 /* If already something, avoid doing system calls. */ | |
| 1643 if (detect_input_pending ()) | |
| 1644 { | |
| 1645 return; | |
| 1646 } | |
| 1647 /* Clear a flag, and tell ast routine above to set it. */ | |
| 1648 SYS$CLREF (input_ef); | |
| 1649 waiting_for_ast = 1; | |
| 1650 /* Check for timing error: ast happened while we were doing that. */ | |
| 1651 if (!detect_input_pending ()) | |
| 1652 { | |
| 1653 /* No timing error: wait for flag to be set. */ | |
| 1654 SYS$CANTIM (1, 0); | |
| 1655 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
| 1656 SYS$WFLOR (timer_ef, timer_eflist); /* Wait for timer expiry or input */ | |
| 1657 } | |
| 1658 waiting_for_ast = 0; | |
| 1659 } | |
| 1660 | |
| 1661 /* The standard `sleep' routine works some other way | |
| 1662 and it stops working if you have ever quit out of it. | |
| 1663 This one continues to work. */ | |
| 1664 | |
| 1665 sys_sleep (timeval) | |
| 1666 int timeval; | |
| 1667 { | |
| 1668 int time [2]; | |
| 1669 static int zero = 0; | |
| 1670 static int large = -10000000; | |
| 1671 | |
| 1672 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
| 1673 | |
| 1674 SYS$CANTIM (1, 0); | |
| 1675 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
| 1676 SYS$WAITFR (timer_ef); /* Wait for timer expiry only */ | |
| 1677 } | |
| 1678 | |
| 1679 init_sigio () | |
| 1680 { | |
| 1681 request_sigio (); | |
| 1682 } | |
| 1683 | |
| 1684 reset_sigio () | |
| 1685 { | |
| 1686 unrequest_sigio (); | |
| 1687 } | |
| 1688 | |
| 1689 request_sigio () | |
| 1690 { | |
| 1691 croak ("request sigio"); | |
| 1692 } | |
| 1693 | |
| 1694 unrequest_sigio () | |
| 1695 { | |
| 1696 croak ("unrequest sigio"); | |
| 1697 } | |
| 1698 | |
| 1699 #endif /* VMS */ | |
| 1700 | |
| 1701 /* Note that VMS compiler won't accept defined (CANNOT_DUMP). */ | |
| 1702 #ifndef CANNOT_DUMP | |
| 1703 #define NEED_STARTS | |
| 1704 #endif | |
| 1705 | |
| 1706 #ifndef SYSTEM_MALLOC | |
| 1707 #ifndef NEED_STARTS | |
| 1708 #define NEED_STARTS | |
| 1709 #endif | |
| 1710 #endif | |
| 1711 | |
| 1712 #ifdef NEED_STARTS | |
| 1713 /* Some systems that cannot dump also cannot implement these. */ | |
| 1714 | |
| 1715 /* | |
| 1716 * Return the address of the start of the text segment prior to | |
| 1717 * doing an unexec. After unexec the return value is undefined. | |
| 1718 * See crt0.c for further explanation and _start. | |
| 1719 * | |
| 1720 */ | |
| 1721 | |
| 1722 #ifndef CANNOT_UNEXEC | |
| 1723 char * | |
| 1724 start_of_text () | |
| 1725 { | |
| 1726 #ifdef TEXT_START | |
| 1727 return ((char *) TEXT_START); | |
| 1728 #else | |
| 1729 #ifdef GOULD | |
| 1730 extern csrt (); | |
| 1731 return ((char *) csrt); | |
| 1732 #else /* not GOULD */ | |
| 1733 extern int _start (); | |
| 1734 return ((char *) _start); | |
| 1735 #endif /* GOULD */ | |
| 1736 #endif /* TEXT_START */ | |
| 1737 } | |
| 1738 #endif /* not CANNOT_UNEXEC */ | |
| 1739 | |
| 1740 /* | |
| 1741 * Return the address of the start of the data segment prior to | |
| 1742 * doing an unexec. After unexec the return value is undefined. | |
| 1743 * See crt0.c for further information and definition of data_start. | |
| 1744 * | |
| 1745 * Apparently, on BSD systems this is etext at startup. On | |
| 1746 * USG systems (swapping) this is highly mmu dependent and | |
| 1747 * is also dependent on whether or not the program is running | |
| 1748 * with shared text. Generally there is a (possibly large) | |
| 1749 * gap between end of text and start of data with shared text. | |
| 1750 * | |
| 1751 * On Uniplus+ systems with shared text, data starts at a | |
| 1752 * fixed address. Each port (from a given oem) is generally | |
| 1753 * different, and the specific value of the start of data can | |
| 1754 * be obtained via the UniPlus+ specific "uvar" system call, | |
| 1755 * however the method outlined in crt0.c seems to be more portable. | |
| 1756 * | |
| 1757 * Probably what will have to happen when a USG unexec is available, | |
| 1758 * at least on UniPlus, is temacs will have to be made unshared so | |
| 1759 * that text and data are contiguous. Then once loadup is complete, | |
| 1760 * unexec will produce a shared executable where the data can be | |
| 1761 * at the normal shared text boundry and the startofdata variable | |
| 1762 * will be patched by unexec to the correct value. | |
| 1763 * | |
| 1764 */ | |
| 1765 | |
| 1766 char * | |
| 1767 start_of_data () | |
| 1768 { | |
| 1769 #ifdef DATA_START | |
| 1770 return ((char *) DATA_START); | |
| 1771 #else | |
|
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1772 #ifdef ORDINARY_LINK |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1773 /* |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1774 * This is a hack. Since we're not linking crt0.c or pre_crt0.c, |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1775 * data_start isn't defined. We take the address of environ, which |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1776 * is known to live at or near the start of the system crt0.c, and |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1777 * we don't sweat the handful of bytes that might lose. |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1778 */ |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1779 extern char **environ; |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1780 |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1781 return((char *) &environ); |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1782 #else |
| 491 | 1783 extern int data_start; |
| 1784 return ((char *) &data_start); | |
|
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1785 #endif /* ORDINARY_LINK */ |
|
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
1786 #endif /* DATA_START */ |
| 491 | 1787 } |
| 1788 #endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ | |
| 1789 | |
| 1790 #ifndef CANNOT_DUMP | |
| 1791 /* Some systems that cannot dump also cannot implement these. */ | |
| 1792 | |
| 1793 /* | |
| 1794 * Return the address of the end of the text segment prior to | |
| 1795 * doing an unexec. After unexec the return value is undefined. | |
| 1796 */ | |
| 1797 | |
| 1798 char * | |
| 1799 end_of_text () | |
| 1800 { | |
| 1801 #ifdef TEXT_END | |
| 1802 return ((char *) TEXT_END); | |
| 1803 #else | |
| 1804 extern int etext; | |
| 1805 return ((char *) &etext); | |
| 1806 #endif | |
| 1807 } | |
| 1808 | |
| 1809 /* | |
| 1810 * Return the address of the end of the data segment prior to | |
| 1811 * doing an unexec. After unexec the return value is undefined. | |
| 1812 */ | |
| 1813 | |
| 1814 char * | |
| 1815 end_of_data () | |
| 1816 { | |
| 1817 #ifdef DATA_END | |
| 1818 return ((char *) DATA_END); | |
| 1819 #else | |
| 1820 extern int edata; | |
| 1821 return ((char *) &edata); | |
| 1822 #endif | |
| 1823 } | |
| 1824 | |
| 1825 #endif /* not CANNOT_DUMP */ | |
| 1826 | |
| 1827 /* Get_system_name returns as its value | |
| 1828 a string for the Lisp function system-name to return. */ | |
| 1829 | |
| 1830 #ifdef BSD4_1 | |
| 1831 #include <whoami.h> | |
| 1832 #endif | |
| 1833 | |
|
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1834 /* Can't have this within the function since `static' is #defined to |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1835 nothing for some USG systems. */ |
| 491 | 1836 #ifdef USG |
|
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1837 #ifdef HAVE_GETHOSTNAME |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1838 static char get_system_name_name[256]; |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1839 #else /* not HAVE_GETHOSTNAME */ |
| 491 | 1840 static struct utsname get_system_name_name; |
|
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1841 #endif /* not HAVE_GETHOSTNAME */ |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1842 #endif /* USG */ |
| 491 | 1843 |
|
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1844 #ifndef BSD4_1 |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1845 #ifndef USG |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1846 #ifndef VMS |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1847 #ifdef HAVE_SOCKETS |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1848 #include <sys/socket.h> |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1849 #include <netdb.h> |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1850 #endif /* HAVE_SOCKETS */ |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1851 #endif /* not VMS */ |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1852 #endif /* not USG */ |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1853 #endif /* not BSD4_1 */ |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1854 |
| 491 | 1855 char * |
| 1856 get_system_name () | |
| 1857 { | |
| 1858 #ifdef USG | |
|
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1859 #ifdef HAVE_GETHOSTNAME |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1860 gethostname (get_system_name_name, sizeof (get_system_name_name)); |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1861 return get_system_name_name; |
|
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1862 #else /* not HAVE_GETHOSTNAME */ |
| 491 | 1863 uname (&get_system_name_name); |
| 1864 return (get_system_name_name.nodename); | |
|
1496
f9010847a5f5
(get_system_name): Use gethostname for USG systems
Richard M. Stallman <rms@gnu.org>
parents:
1203
diff
changeset
|
1865 #endif /* not HAVE_GETHOSTNAME */ |
| 491 | 1866 #else /* Not USG */ |
| 1867 #ifdef BSD4_1 | |
| 1868 return sysname; | |
| 1869 #else /* not USG, not 4.1 */ | |
| 1870 static char system_name_saved[32]; | |
| 1871 #ifdef VMS | |
| 1872 char *sp; | |
| 1873 if ((sp = egetenv ("SYS$NODE")) == 0) | |
| 1874 sp = "vax-vms"; | |
| 1875 else | |
| 1876 { | |
| 1877 char *end; | |
| 1878 | |
| 1879 if ((end = index (sp, ':')) != 0) | |
| 1880 *end = '\0'; | |
| 1881 } | |
| 1882 strcpy (system_name_saved, sp); | |
| 1883 #else /* not VMS */ | |
| 1884 gethostname (system_name_saved, sizeof (system_name_saved)); | |
|
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1885 #ifdef HAVE_SOCKETS |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1886 /* Turn the hostname into the official, fully-qualified hostname. |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1887 Don't do this if we're going to dump; this can confuse system |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1888 libraries on some machines and make the dumped emacs core dump. */ |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1889 #ifndef CANNOT_DUMP |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1890 if (initialized) |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1891 #endif /* not CANNOT_DUMP */ |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1892 { |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1893 struct hostent *hp; |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1894 hp = gethostbyname (system_name_saved); |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1895 if (hp && strlen (hp->h_name) < sizeof(system_name_saved)) |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1896 strcpy (system_name_saved, hp->h_name); |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1897 } |
|
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
1898 #endif /* HAVE_SOCKETS */ |
| 491 | 1899 #endif /* not VMS */ |
| 1900 return system_name_saved; | |
| 1901 #endif /* not USG, not 4.1 */ | |
| 1902 #endif /* not USG */ | |
| 1903 } | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1904 |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1905 #ifdef VMS |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1906 #ifndef HAVE_GETHOSTNAME |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1907 void gethostname(buf, len) |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1908 char *buf; |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1909 int len; |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1910 { |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1911 char *s; |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1912 s = getenv ("SYS$NODE"); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1913 if (s == NULL) |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1914 buf[0] = '\0'; |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1915 else { |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1916 strncpy (buf, s, len - 2); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1917 buf[len - 1] = '\0'; |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1918 } /* else */ |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1919 } /* static void gethostname */ |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1920 #endif /* ! HAVE_GETHOSTNAME */ |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1921 #endif /* VMS */ |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
1922 |
| 491 | 1923 |
| 1924 #ifndef VMS | |
| 1925 #ifndef HAVE_SELECT | |
| 1926 | |
| 1927 #ifdef HAVE_X_WINDOWS | |
| 1928 /* Cause explanatory error message at compile time, | |
| 1929 since the select emulation is not good enough for X. */ | |
| 1930 int *x = &x_windows_lose_if_no_select_system_call; | |
| 1931 #endif | |
| 1932 | |
| 1933 /* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs | |
| 1934 * Only checks read descriptors. | |
| 1935 */ | |
| 1936 /* How long to wait between checking fds in select */ | |
| 1937 #define SELECT_PAUSE 1 | |
| 1938 int select_alarmed; | |
| 1939 | |
| 1940 /* For longjmp'ing back to read_input_waiting. */ | |
| 1941 | |
| 1942 jmp_buf read_alarm_throw; | |
| 1943 | |
| 1944 /* Nonzero if the alarm signal should throw back to read_input_waiting. | |
| 1945 The read_socket_hook function sets this to 1 while it is waiting. */ | |
| 1946 | |
| 1947 int read_alarm_should_throw; | |
| 1948 | |
| 1949 SIGTYPE | |
| 1950 select_alarm () | |
| 1951 { | |
| 1952 select_alarmed = 1; | |
| 1953 #ifdef BSD4_1 | |
| 1954 sigrelse (SIGALRM); | |
| 1955 #else /* not BSD4_1 */ | |
| 1956 signal (SIGALRM, SIG_IGN); | |
| 1957 #endif /* not BSD4_1 */ | |
| 1958 if (read_alarm_should_throw) | |
| 1959 longjmp (read_alarm_throw, 1); | |
| 1960 } | |
| 1961 | |
| 1962 /* Only rfds are checked. */ | |
| 1963 int | |
| 1964 select (nfds, rfds, wfds, efds, timeout) | |
| 1965 int nfds; | |
| 1966 int *rfds, *wfds, *efds, *timeout; | |
| 1967 { | |
| 1968 int ravail = 0, orfds = 0, old_alarm; | |
| 1969 int timeoutval = timeout ? *timeout : 100000; | |
| 1970 int *local_timeout = &timeoutval; | |
| 1971 extern int proc_buffered_char[]; | |
| 1972 #ifndef subprocesses | |
| 1973 int process_tick = 0, update_tick = 0; | |
| 1974 #else | |
| 1975 extern int process_tick, update_tick; | |
| 1976 #endif | |
| 1977 SIGTYPE (*old_trap) (); | |
| 1978 unsigned char buf; | |
| 1979 | |
| 1980 if (rfds) | |
| 1981 { | |
| 1982 orfds = *rfds; | |
| 1983 *rfds = 0; | |
| 1984 } | |
| 1985 if (wfds) | |
| 1986 *wfds = 0; | |
| 1987 if (efds) | |
| 1988 *efds = 0; | |
| 1989 | |
| 1990 /* If we are looking only for the terminal, with no timeout, | |
| 1991 just read it and wait -- that's more efficient. */ | |
| 1992 if (orfds == 1 && *local_timeout == 100000 && process_tick == update_tick) | |
| 1993 { | |
| 1994 if (! detect_input_pending ()) | |
| 1995 read_input_waiting (); | |
| 1996 *rfds = 1; | |
| 1997 return 1; | |
| 1998 } | |
| 1999 | |
| 2000 /* Once a second, till the timer expires, check all the flagged read | |
| 2001 * descriptors to see if any input is available. If there is some then | |
| 2002 * set the corresponding bit in the return copy of rfds. | |
| 2003 */ | |
| 2004 while (1) | |
| 2005 { | |
| 2006 register int to_check, bit, fd; | |
| 2007 | |
| 2008 if (rfds) | |
| 2009 { | |
| 2010 for (to_check = nfds, bit = 1, fd = 0; --to_check >= 0; bit <<= 1, fd++) | |
| 2011 { | |
| 2012 if (orfds & bit) | |
| 2013 { | |
| 2014 int avail = 0, status = 0; | |
| 2015 | |
| 2016 if (bit == 1) | |
| 2017 avail = detect_input_pending (); /* Special keyboard handler */ | |
| 2018 else | |
| 2019 { | |
| 2020 #ifdef FIONREAD | |
| 2021 status = ioctl (fd, FIONREAD, &avail); | |
| 2022 #else /* no FIONREAD */ | |
| 2023 /* Hoping it will return -1 if nothing available | |
| 2024 or 0 if all 0 chars requested are read. */ | |
| 2025 if (proc_buffered_char[fd] >= 0) | |
| 2026 avail = 1; | |
| 2027 else | |
| 2028 { | |
| 2029 avail = read (fd, &buf, 1); | |
| 2030 if (avail > 0) | |
| 2031 proc_buffered_char[fd] = buf; | |
| 2032 } | |
| 2033 #endif /* no FIONREAD */ | |
| 2034 } | |
| 2035 if (status >= 0 && avail > 0) | |
| 2036 { | |
| 2037 (*rfds) |= bit; | |
| 2038 ravail++; | |
| 2039 } | |
| 2040 } | |
| 2041 } | |
| 2042 } | |
| 2043 if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick) | |
| 2044 break; | |
| 2045 old_alarm = alarm (0); | |
|
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2046 old_trap = signal (SIGALRM, select_alarm); |
| 491 | 2047 select_alarmed = 0; |
| 2048 alarm (SELECT_PAUSE); | |
| 2049 /* Wait for a SIGALRM (or maybe a SIGTINT) */ | |
| 2050 while (select_alarmed == 0 && *local_timeout != 0 | |
| 2051 && process_tick == update_tick) | |
| 2052 { | |
| 2053 /* If we are interested in terminal input, | |
| 2054 wait by reading the terminal. | |
| 2055 That makes instant wakeup for terminal input at least. */ | |
| 2056 if (orfds & 1) | |
| 2057 { | |
| 2058 read_input_waiting (); | |
| 2059 if (detect_input_pending ()) | |
| 2060 select_alarmed = 1; | |
| 2061 } | |
| 2062 else | |
| 2063 pause (); | |
| 2064 } | |
| 2065 (*local_timeout) -= SELECT_PAUSE; | |
| 2066 /* Reset the old alarm if there was one */ | |
| 2067 alarm (0); | |
| 2068 signal (SIGALRM, old_trap); | |
| 2069 if (old_alarm != 0) | |
| 2070 { | |
| 2071 /* Reset or forge an interrupt for the original handler. */ | |
| 2072 old_alarm -= SELECT_PAUSE; | |
| 2073 if (old_alarm <= 0) | |
| 2074 kill (getpid (), SIGALRM); /* Fake an alarm with the orig' handler */ | |
| 2075 else | |
| 2076 alarm (old_alarm); | |
| 2077 } | |
| 2078 if (*local_timeout == 0) /* Stop on timer being cleared */ | |
| 2079 break; | |
| 2080 } | |
| 2081 return ravail; | |
| 2082 } | |
| 2083 | |
| 2084 /* Read keyboard input into the standard buffer, | |
| 2085 waiting for at least one character. */ | |
| 2086 | |
| 2087 /* Make all keyboard buffers much bigger when using X windows. */ | |
| 2088 #ifdef HAVE_X_WINDOWS | |
| 2089 #define BUFFER_SIZE_FACTOR 16 | |
| 2090 #else | |
| 2091 #define BUFFER_SIZE_FACTOR 1 | |
| 2092 #endif | |
| 2093 | |
| 2094 read_input_waiting () | |
| 2095 { | |
| 2096 char buf[256 * BUFFER_SIZE_FACTOR]; | |
| 2097 struct input_event e; | |
|
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2098 int nread, i; |
|
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2099 extern int quit_char; |
| 491 | 2100 |
| 2101 if (read_socket_hook) | |
| 2102 { | |
| 2103 read_alarm_should_throw = 0; | |
| 2104 if (! setjmp (read_alarm_throw)) | |
| 2105 nread = (*read_socket_hook) (0, buf, 256 * BUFFER_SIZE_FACTOR, 1, 0); | |
| 2106 else | |
| 2107 nread = -1; | |
| 2108 } | |
| 2109 else | |
| 2110 nread = read (fileno (stdin), buf, 1); | |
| 2111 | |
| 2112 /* Scan the chars for C-g and store them in kbd_buffer. */ | |
| 2113 e.kind = ascii_keystroke; | |
|
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2114 e.frame_or_window = selected_frame; |
|
2589
5f41134610a6
(read_pending_input): Fix the garbaged-modifiers bug under System Vs previous
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2439
diff
changeset
|
2115 e.modifiers = 0; |
| 491 | 2116 for (i = 0; i < nread; i++) |
| 2117 { | |
|
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2118 /* Convert chars > 0177 to meta events if desired. |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2119 We do this under the same conditions that read_avail_input does. */ |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2120 if (read_socket_hook == 0) |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2121 { |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2122 /* If the user says she has a meta key, then believe her. */ |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2123 if (meta_key == 1 && (buf[i] & 0x80)) |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2124 e.modifiers = meta_modifier; |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2125 if (meta_key != 2) |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2126 buf[i] &= ~0x80; |
|
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2127 } |
|
4772
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2128 |
| 491 | 2129 XSET (e.code, Lisp_Int, buf[i]); |
| 2130 kbd_buffer_store_event (&e); | |
| 2131 /* Don't look at input that follows a C-g too closely. | |
| 2132 This reduces lossage due to autorepeat on C-g. */ | |
|
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2133 if (buf[i] == quit_char) |
| 491 | 2134 break; |
| 2135 } | |
| 2136 } | |
| 2137 | |
| 2138 #endif /* not HAVE_SELECT */ | |
| 2139 #endif /* not VMS */ | |
| 2140 | |
| 2141 #ifdef BSD4_1 | |
| 2142 /* | |
| 2143 * Partially emulate 4.2 open call. | |
| 2144 * open is defined as this in 4.1. | |
| 2145 * | |
| 2146 * - added by Michael Bloom @ Citicorp/TTI | |
| 2147 * | |
| 2148 */ | |
| 2149 | |
| 2150 int | |
| 2151 sys_open (path, oflag, mode) | |
| 2152 char *path; | |
| 2153 int oflag, mode; | |
| 2154 { | |
| 2155 if (oflag & O_CREAT) | |
| 2156 return creat (path, mode); | |
| 2157 else | |
| 2158 return open (path, oflag); | |
| 2159 } | |
| 2160 | |
| 2161 init_sigio () | |
| 2162 { | |
| 2163 if (noninteractive) | |
| 2164 return; | |
| 2165 lmode = LINTRUP | lmode; | |
| 2166 ioctl (0, TIOCLSET, &lmode); | |
| 2167 } | |
| 2168 | |
| 2169 reset_sigio () | |
| 2170 { | |
| 2171 if (noninteractive) | |
| 2172 return; | |
| 2173 lmode = ~LINTRUP & lmode; | |
| 2174 ioctl (0, TIOCLSET, &lmode); | |
| 2175 } | |
| 2176 | |
| 2177 request_sigio () | |
| 2178 { | |
| 2179 sigrelse (SIGTINT); | |
| 2180 | |
| 2181 interrupts_deferred = 0; | |
| 2182 } | |
| 2183 | |
| 2184 unrequest_sigio () | |
| 2185 { | |
| 2186 sighold (SIGTINT); | |
| 2187 | |
| 2188 interrupts_deferred = 1; | |
| 2189 } | |
| 2190 | |
| 2191 /* still inside #ifdef BSD4_1 */ | |
| 2192 #ifdef subprocesses | |
| 2193 | |
| 2194 int sigheld; /* Mask of held signals */ | |
| 2195 | |
| 2196 sigholdx (signum) | |
| 2197 int signum; | |
| 2198 { | |
| 2199 sigheld |= sigbit (signum); | |
| 2200 sighold (signum); | |
| 2201 } | |
| 2202 | |
| 2203 sigisheld (signum) | |
| 2204 int signum; | |
| 2205 { | |
| 2206 sigheld |= sigbit (signum); | |
| 2207 } | |
| 2208 | |
| 2209 sigunhold (signum) | |
| 2210 int signum; | |
| 2211 { | |
| 2212 sigheld &= ~sigbit (signum); | |
| 2213 sigrelse (signum); | |
| 2214 } | |
| 2215 | |
| 2216 sigfree () /* Free all held signals */ | |
| 2217 { | |
| 2218 int i; | |
| 2219 for (i = 0; i < NSIG; i++) | |
| 2220 if (sigheld & sigbit (i)) | |
| 2221 sigrelse (i); | |
| 2222 sigheld = 0; | |
| 2223 } | |
| 2224 | |
| 2225 sigbit (i) | |
| 2226 { | |
| 2227 return 1 << (i - 1); | |
| 2228 } | |
| 2229 #endif /* subprocesses */ | |
| 2230 #endif /* BSD4_1 */ | |
| 2231 | |
| 2232 /* POSIX signals support - DJB */ | |
| 2233 /* Anyone with POSIX signals should have ANSI C declarations */ | |
| 2234 | |
| 2235 #ifdef POSIX_SIGNALS | |
| 2236 | |
| 2237 sigset_t old_mask, empty_mask, full_mask, temp_mask; | |
| 2238 static struct sigaction new_action, old_action; | |
| 2239 | |
| 2240 init_signals () | |
| 2241 { | |
|
2913
409c1022bad5
Some changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
2873
diff
changeset
|
2242 sigemptyset (&empty_mask); |
|
409c1022bad5
Some changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
2873
diff
changeset
|
2243 sigfillset (&full_mask); |
| 491 | 2244 } |
| 2245 | |
| 2246 signal_handler_t | |
| 2247 sys_signal (int signal_number, signal_handler_t action) | |
| 2248 { | |
| 2249 #ifdef DGUX | |
| 2250 /* This gets us restartable system calls for efficiency. | |
| 2251 The "else" code will works as well. */ | |
| 2252 return (berk_signal (signal_number, action)); | |
| 2253 #else | |
| 2254 sigemptyset (&new_action.sa_mask); | |
| 2255 new_action.sa_handler = action; | |
|
3292
6209d0e98e35
(sys_signal): Use 0, not NULL, to set sa_flags.
Richard M. Stallman <rms@gnu.org>
parents:
3268
diff
changeset
|
2256 new_action.sa_flags = 0; |
| 709 | 2257 sigaction (signal_number, &new_action, &old_action); |
| 491 | 2258 return (old_action.sa_handler); |
| 2259 #endif /* DGUX */ | |
| 2260 } | |
| 2261 | |
| 638 | 2262 #ifndef __GNUC__ |
| 2263 /* If we're compiling with GCC, we don't need this function, since it | |
| 2264 can be written as a macro. */ | |
| 2265 sigset_t | |
| 2266 sys_sigmask (int sig) | |
| 2267 { | |
| 2268 sigset_t mask; | |
| 2269 sigemptyset (&mask); | |
| 2270 sigaddset (&mask, sig); | |
| 2271 return mask; | |
| 2272 } | |
| 2273 #endif | |
| 2274 | |
| 491 | 2275 int |
| 2276 sys_sigpause (sigset_t new_mask) | |
| 2277 { | |
| 2278 /* pause emulating berk sigpause... */ | |
| 2279 sigsuspend (&new_mask); | |
| 2280 return (EINTR); | |
| 2281 } | |
| 2282 | |
| 2283 /* I'd like to have these guys return pointers to the mask storage in here, | |
| 2284 but there'd be trouble if the code was saving multiple masks. I'll be | |
| 2285 safe and pass the structure. It normally won't be more than 2 bytes | |
| 2286 anyhow. - DJB */ | |
| 2287 | |
| 2288 sigset_t | |
| 2289 sys_sigblock (sigset_t new_mask) | |
| 2290 { | |
| 2291 sigset_t old_mask; | |
| 2292 sigprocmask (SIG_BLOCK, &new_mask, &old_mask); | |
| 2293 return (old_mask); | |
| 2294 } | |
| 2295 | |
| 2296 sigset_t | |
| 2297 sys_sigunblock (sigset_t new_mask) | |
| 2298 { | |
| 2299 sigset_t old_mask; | |
| 2300 sigprocmask (SIG_UNBLOCK, &new_mask, &old_mask); | |
| 2301 return (old_mask); | |
| 2302 } | |
| 2303 | |
| 2304 sigset_t | |
| 2305 sys_sigsetmask (sigset_t new_mask) | |
| 2306 { | |
| 2307 sigset_t old_mask; | |
| 2308 sigprocmask (SIG_SETMASK, &new_mask, &old_mask); | |
| 2309 return (old_mask); | |
| 2310 } | |
| 2311 | |
| 2312 #endif /* POSIX_SIGNALS */ | |
| 2313 | |
| 2314 #ifndef BSTRING | |
| 2315 | |
|
4708
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2316 #ifndef bzero |
|
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2317 |
| 491 | 2318 void |
| 2319 bzero (b, length) | |
| 2320 register char *b; | |
| 2321 register int length; | |
| 2322 { | |
| 2323 #ifdef VMS | |
| 2324 short zero = 0; | |
| 2325 long max_str = 65535; | |
| 2326 | |
| 2327 while (length > max_str) { | |
| 2328 (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); | |
| 2329 length -= max_str; | |
| 2330 b += max_str; | |
| 2331 } | |
| 2332 max_str = length; | |
| 2333 (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); | |
| 2334 #else | |
| 2335 while (length-- > 0) | |
| 2336 *b++ = 0; | |
| 2337 #endif /* not VMS */ | |
| 2338 } | |
| 2339 | |
|
4708
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2340 #endif /* no bzero */ |
|
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2341 |
|
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2342 #ifndef bcopy |
| 491 | 2343 /* Saying `void' requires a declaration, above, where bcopy is used |
| 2344 and that declaration causes pain for systems where bcopy is a macro. */ | |
| 2345 bcopy (b1, b2, length) | |
| 2346 register char *b1; | |
| 2347 register char *b2; | |
| 2348 register int length; | |
| 2349 { | |
| 2350 #ifdef VMS | |
| 2351 long max_str = 65535; | |
| 2352 | |
| 2353 while (length > max_str) { | |
| 2354 (void) LIB$MOVC3 (&max_str, b1, b2); | |
| 2355 length -= max_str; | |
| 2356 b1 += max_str; | |
| 2357 b2 += max_str; | |
| 2358 } | |
| 2359 max_str = length; | |
| 2360 (void) LIB$MOVC3 (&length, b1, b2); | |
| 2361 #else | |
| 2362 while (length-- > 0) | |
| 2363 *b2++ = *b1++; | |
| 2364 #endif /* not VMS */ | |
| 2365 } | |
|
4708
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2366 #endif /* no bcopy */ |
|
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2367 |
|
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2368 #ifndef bcmp |
| 491 | 2369 int |
| 2370 bcmp (b1, b2, length) /* This could be a macro! */ | |
| 2371 register char *b1; | |
| 2372 register char *b2; | |
| 2373 register int length; | |
| 2374 { | |
| 2375 #ifdef VMS | |
| 2376 struct dsc$descriptor_s src1 = {length, DSC$K_DTYPE_T, DSC$K_CLASS_S, b1}; | |
| 2377 struct dsc$descriptor_s src2 = {length, DSC$K_DTYPE_T, DSC$K_CLASS_S, b2}; | |
| 2378 | |
| 2379 return STR$COMPARE (&src1, &src2); | |
| 2380 #else | |
| 2381 while (length-- > 0) | |
| 2382 if (*b1++ != *b2++) | |
| 2383 return 1; | |
| 2384 | |
| 2385 return 0; | |
| 2386 #endif /* not VMS */ | |
| 2387 } | |
|
4708
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2388 #endif /* no bcmp */ |
|
a915b866ac7f
(bzero, bcopy, bcmp): Don't define as functions
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
2389 |
| 491 | 2390 #endif /* not BSTRING */ |
| 2391 | |
|
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
2392 #ifndef HAVE_RANDOM |
| 491 | 2393 #ifdef USG |
| 2394 /* | |
| 2395 * The BSD random returns numbers in the range of | |
| 2396 * 0 to 2e31 - 1. The USG rand returns numbers in the | |
| 2397 * range of 0 to 2e15 - 1. This is probably not significant | |
| 2398 * in this usage. | |
| 2399 */ | |
| 2400 | |
| 2401 long | |
| 2402 random () | |
| 2403 { | |
| 2404 /* Arrange to return a range centered on zero. */ | |
| 2405 return (rand () << 15) + rand () - (1 << 29); | |
| 2406 } | |
| 2407 | |
| 2408 srandom (arg) | |
| 2409 int arg; | |
| 2410 { | |
| 2411 srand (arg); | |
| 2412 } | |
| 2413 | |
| 2414 #endif /* USG */ | |
| 2415 | |
| 2416 #ifdef BSD4_1 | |
| 2417 long random () | |
| 2418 { | |
| 2419 /* Arrange to return a range centered on zero. */ | |
| 2420 return (rand () << 15) + rand () - (1 << 29); | |
| 2421 } | |
| 2422 | |
| 2423 srandom (arg) | |
| 2424 int arg; | |
| 2425 { | |
| 2426 srand (arg); | |
| 2427 } | |
| 2428 #endif /* BSD4_1 */ | |
|
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
2429 #endif |
| 491 | 2430 |
| 2431 #ifdef WRONG_NAME_INSQUE | |
| 2432 | |
| 2433 insque (q,p) | |
| 2434 caddr_t q,p; | |
| 2435 { | |
| 2436 _insque (q,p); | |
| 2437 } | |
| 2438 | |
| 2439 #endif | |
| 2440 | |
| 2441 #ifdef VMS | |
| 2442 | |
| 2443 #ifdef getenv | |
| 2444 /* If any place else asks for the TERM variable, | |
| 2445 allow it to be overridden with the EMACS_TERM variable | |
| 2446 before attempting to translate the logical name TERM. As a last | |
| 2447 resort, ask for VAX C's special idea of the TERM variable. */ | |
| 2448 #undef getenv | |
| 2449 char * | |
| 2450 sys_getenv (name) | |
| 2451 char *name; | |
| 2452 { | |
| 2453 register char *val; | |
| 2454 static char buf[256]; | |
| 2455 static struct dsc$descriptor_s equiv | |
| 2456 = {sizeof (buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf}; | |
| 2457 static struct dsc$descriptor_s d_name | |
| 2458 = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; | |
| 2459 short eqlen; | |
| 2460 | |
| 2461 if (!strcmp (name, "TERM")) | |
| 2462 { | |
| 2463 val = (char *) getenv ("EMACS_TERM"); | |
| 2464 if (val) | |
| 2465 return val; | |
| 2466 } | |
| 2467 | |
| 2468 d_name.dsc$w_length = strlen (name); | |
| 2469 d_name.dsc$a_pointer = name; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
2470 if (LIB$SYS_TRNLOG (&d_name, &eqlen, &equiv) == 1) |
| 491 | 2471 { |
| 2472 char *str = (char *) xmalloc (eqlen + 1); | |
| 2473 bcopy (buf, str, eqlen); | |
| 2474 str[eqlen] = '\0'; | |
| 2475 /* This is a storage leak, but a pain to fix. With luck, | |
| 2476 no one will ever notice. */ | |
| 2477 return str; | |
| 2478 } | |
| 2479 return (char *) getenv (name); | |
| 2480 } | |
| 2481 #endif /* getenv */ | |
| 2482 | |
| 2483 #ifdef abort | |
| 2484 /* Since VMS doesn't believe in core dumps, the only way to debug this beast is | |
| 2485 to force a call on the debugger from within the image. */ | |
| 2486 #undef abort | |
| 2487 sys_abort () | |
| 2488 { | |
| 2489 reset_sys_modes (); | |
| 2490 LIB$SIGNAL (SS$_DEBUG); | |
| 2491 } | |
| 2492 #endif /* abort */ | |
| 2493 #endif /* VMS */ | |
| 2494 | |
| 2495 #ifdef VMS | |
| 2496 #ifdef LINK_CRTL_SHARE | |
| 2497 #ifdef SHAREABLE_LIB_BUG | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
2498 /* Variables declared noshare and initialized in sharable libraries |
| 491 | 2499 cannot be shared. The VMS linker incorrectly forces you to use a private |
| 2500 version which is uninitialized... If not for this "feature", we | |
| 2501 could use the C library definition of sys_nerr and sys_errlist. */ | |
| 2502 int sys_nerr = 35; | |
| 2503 char *sys_errlist[] = | |
| 2504 { | |
| 2505 "error 0", | |
| 2506 "not owner", | |
| 2507 "no such file or directory", | |
| 2508 "no such process", | |
| 2509 "interrupted system call", | |
| 2510 "i/o error", | |
| 2511 "no such device or address", | |
| 2512 "argument list too long", | |
| 2513 "exec format error", | |
| 2514 "bad file number", | |
| 2515 "no child process", | |
| 2516 "no more processes", | |
| 2517 "not enough memory", | |
| 2518 "permission denied", | |
| 2519 "bad address", | |
| 2520 "block device required", | |
| 2521 "mount devices busy", | |
| 2522 "file exists", | |
| 2523 "cross-device link", | |
| 2524 "no such device", | |
| 2525 "not a directory", | |
| 2526 "is a directory", | |
| 2527 "invalid argument", | |
| 2528 "file table overflow", | |
| 2529 "too many open files", | |
| 2530 "not a typewriter", | |
| 2531 "text file busy", | |
| 2532 "file too big", | |
| 2533 "no space left on device", | |
| 2534 "illegal seek", | |
| 2535 "read-only file system", | |
| 2536 "too many links", | |
| 2537 "broken pipe", | |
| 2538 "math argument", | |
| 2539 "result too large", | |
| 2540 "I/O stream empty", | |
| 2541 "vax/vms specific error code nontranslatable error" | |
| 2542 }; | |
| 2543 #endif /* SHAREABLE_LIB_BUG */ | |
| 2544 #endif /* LINK_CRTL_SHARE */ | |
| 2545 #endif /* VMS */ | |
| 2546 | |
| 2547 #ifdef INTERRUPTIBLE_OPEN | |
| 2548 | |
| 2549 int | |
| 2550 /* VARARGS 2 */ | |
| 2551 sys_open (path, oflag, mode) | |
| 2552 char *path; | |
| 2553 int oflag, mode; | |
| 2554 { | |
| 2555 register int rtnval; | |
| 2556 | |
| 2557 while ((rtnval = open (path, oflag, mode)) == -1 | |
| 2558 && (errno == EINTR)); | |
| 2559 return (rtnval); | |
| 2560 } | |
| 2561 | |
| 2562 #endif /* INTERRUPTIBLE_OPEN */ | |
| 2563 | |
| 2564 #ifdef INTERRUPTIBLE_CLOSE | |
| 2565 | |
| 2566 sys_close (fd) | |
| 2567 int fd; | |
| 2568 { | |
| 2569 register int rtnval; | |
| 2570 | |
| 2571 while ((rtnval = close (fd)) == -1 | |
| 2572 && (errno == EINTR)); | |
| 2573 return rtnval; | |
| 2574 } | |
| 2575 | |
| 2576 #endif /* INTERRUPTIBLE_CLOSE */ | |
| 2577 | |
| 2578 #ifdef INTERRUPTIBLE_IO | |
| 2579 | |
| 2580 int | |
| 2581 sys_read (fildes, buf, nbyte) | |
| 2582 int fildes; | |
| 2583 char *buf; | |
| 2584 unsigned int nbyte; | |
| 2585 { | |
| 2586 register int rtnval; | |
| 2587 | |
| 2588 while ((rtnval = read (fildes, buf, nbyte)) == -1 | |
| 2589 && (errno == EINTR)); | |
| 2590 return (rtnval); | |
| 2591 } | |
| 2592 | |
| 2593 int | |
| 2594 sys_write (fildes, buf, nbyte) | |
| 2595 int fildes; | |
| 2596 char *buf; | |
| 2597 unsigned int nbyte; | |
| 2598 { | |
|
4772
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2599 register int rtnval, bytes_written; |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2600 |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2601 bytes_written = 0; |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2602 |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2603 while (nbyte > 0) |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2604 { |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2605 rtnval = write (fildes, buf, nbyte); |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2606 |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2607 if (rtnval == -1) |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2608 { |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2609 if (errno == EINTR) |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2610 continue; |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2611 else |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2612 return (-1); |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2613 } |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2614 |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2615 buf += rtnval; |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2616 nbyte -= rtnval; |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2617 bytes_written += rtnval; |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2618 } |
|
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
2619 return (bytes_written); |
| 491 | 2620 } |
| 2621 | |
| 2622 #endif /* INTERRUPTIBLE_IO */ | |
| 2623 | |
|
4430
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2624 #ifndef HAVE_VFORK |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2625 |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2626 /* |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2627 * Substitute fork for vfork on USG flavors. |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2628 */ |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2629 |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2630 vfork () |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2631 { |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2632 return (fork ()); |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2633 } |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2634 |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2635 #endif /* not HAVE_VFORK */ |
|
ecac48eaacce
(vfork): Move this outside the USG conditional.
Richard M. Stallman <rms@gnu.org>
parents:
4142
diff
changeset
|
2636 |
| 491 | 2637 #ifdef USG |
| 2638 /* | |
| 2639 * All of the following are for USG. | |
| 2640 * | |
| 2641 * On USG systems the system calls are INTERRUPTIBLE by signals | |
| 2642 * that the user program has elected to catch. Thus the system call | |
| 2643 * must be retried in these cases. To handle this without massive | |
| 2644 * changes in the source code, we remap the standard system call names | |
| 2645 * to names for our own functions in sysdep.c that do the system call | |
| 2646 * with retries. Actually, for portability reasons, it is good | |
| 2647 * programming practice, as this example shows, to limit all actual | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
2648 * system calls to a single occurrence in the source. Sure, this |
| 491 | 2649 * adds an extra level of function call overhead but it is almost |
| 2650 * always negligible. Fred Fish, Unisoft Systems Inc. | |
| 2651 */ | |
| 2652 | |
|
2913
409c1022bad5
Some changes from Michael K. Johnson for Linux.
Jim Blandy <jimb@redhat.com>
parents:
2873
diff
changeset
|
2653 #ifndef HAVE_SYS_SIGLIST |
| 491 | 2654 char *sys_siglist[NSIG + 1] = |
| 2655 { | |
| 2656 #ifdef AIX | |
| 2657 /* AIX has changed the signals a bit */ | |
| 2658 "bogus signal", /* 0 */ | |
| 2659 "hangup", /* 1 SIGHUP */ | |
| 2660 "interrupt", /* 2 SIGINT */ | |
| 2661 "quit", /* 3 SIGQUIT */ | |
| 2662 "illegal instruction", /* 4 SIGILL */ | |
| 2663 "trace trap", /* 5 SIGTRAP */ | |
| 2664 "IOT instruction", /* 6 SIGIOT */ | |
| 2665 "crash likely", /* 7 SIGDANGER */ | |
| 2666 "floating point exception", /* 8 SIGFPE */ | |
| 2667 "kill", /* 9 SIGKILL */ | |
| 2668 "bus error", /* 10 SIGBUS */ | |
| 2669 "segmentation violation", /* 11 SIGSEGV */ | |
| 2670 "bad argument to system call", /* 12 SIGSYS */ | |
| 2671 "write on a pipe with no one to read it", /* 13 SIGPIPE */ | |
| 2672 "alarm clock", /* 14 SIGALRM */ | |
| 2673 "software termination signum", /* 15 SIGTERM */ | |
| 2674 "user defined signal 1", /* 16 SIGUSR1 */ | |
| 2675 "user defined signal 2", /* 17 SIGUSR2 */ | |
| 2676 "death of a child", /* 18 SIGCLD */ | |
| 2677 "power-fail restart", /* 19 SIGPWR */ | |
| 2678 "bogus signal", /* 20 */ | |
| 2679 "bogus signal", /* 21 */ | |
| 2680 "bogus signal", /* 22 */ | |
| 2681 "bogus signal", /* 23 */ | |
| 2682 "bogus signal", /* 24 */ | |
| 2683 "LAN I/O interrupt", /* 25 SIGAIO */ | |
| 2684 "PTY I/O interrupt", /* 26 SIGPTY */ | |
| 2685 "I/O intervention required", /* 27 SIGIOINT */ | |
| 2686 "HFT grant", /* 28 SIGGRANT */ | |
| 2687 "HFT retract", /* 29 SIGRETRACT */ | |
| 2688 "HFT sound done", /* 30 SIGSOUND */ | |
| 2689 "HFT input ready", /* 31 SIGMSG */ | |
| 2690 #else /* not AIX */ | |
| 2691 "bogus signal", /* 0 */ | |
| 2692 "hangup", /* 1 SIGHUP */ | |
| 2693 "interrupt", /* 2 SIGINT */ | |
| 2694 "quit", /* 3 SIGQUIT */ | |
| 2695 "illegal instruction", /* 4 SIGILL */ | |
| 2696 "trace trap", /* 5 SIGTRAP */ | |
| 2697 "IOT instruction", /* 6 SIGIOT */ | |
| 2698 "EMT instruction", /* 7 SIGEMT */ | |
| 2699 "floating point exception", /* 8 SIGFPE */ | |
| 2700 "kill", /* 9 SIGKILL */ | |
| 2701 "bus error", /* 10 SIGBUS */ | |
| 2702 "segmentation violation", /* 11 SIGSEGV */ | |
| 2703 "bad argument to system call", /* 12 SIGSYS */ | |
| 2704 "write on a pipe with no one to read it", /* 13 SIGPIPE */ | |
| 2705 "alarm clock", /* 14 SIGALRM */ | |
| 2706 "software termination signum", /* 15 SIGTERM */ | |
| 2707 "user defined signal 1", /* 16 SIGUSR1 */ | |
| 2708 "user defined signal 2", /* 17 SIGUSR2 */ | |
| 2709 "death of a child", /* 18 SIGCLD */ | |
| 2710 "power-fail restart", /* 19 SIGPWR */ | |
| 2711 #endif /* not AIX */ | |
| 2712 0 | |
| 2713 }; | |
|
3268
760a82a8767e
* sysdep.c (sys_siglist): Comment out #endif trailer.
Jim Blandy <jimb@redhat.com>
parents:
3239
diff
changeset
|
2714 #endif /* HAVE_SYS_SIGLIST */ |
| 491 | 2715 |
| 2716 /* | |
| 2717 * Warning, this function may not duplicate 4.2 action properly | |
| 2718 * under error conditions. | |
| 2719 */ | |
| 2720 | |
| 2721 #ifndef MAXPATHLEN | |
| 2722 /* In 4.1, param.h fails to define this. */ | |
| 2723 #define MAXPATHLEN 1024 | |
| 2724 #endif | |
| 2725 | |
| 2726 #ifndef HAVE_GETWD | |
| 2727 | |
| 2728 char * | |
| 2729 getwd (pathname) | |
| 2730 char *pathname; | |
| 2731 { | |
| 2732 char *npath, *spath; | |
| 2733 extern char *getcwd (); | |
| 2734 | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2735 BLOCK_INPUT; /* getcwd uses malloc */ |
| 491 | 2736 spath = npath = getcwd ((char *) 0, MAXPATHLEN); |
| 2737 /* On Altos 3068, getcwd can return @hostname/dir, so discard | |
| 2738 up to first slash. Should be harmless on other systems. */ | |
| 2739 while (*npath && *npath != '/') | |
| 2740 npath++; | |
| 2741 strcpy (pathname, npath); | |
| 2742 free (spath); /* getcwd uses malloc */ | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2743 UNBLOCK_INPUT; |
| 491 | 2744 return pathname; |
| 2745 } | |
| 2746 | |
| 2747 #endif /* HAVE_GETWD */ | |
| 2748 | |
| 2749 /* | |
| 2750 * Emulate rename using unlink/link. Note that this is | |
| 2751 * only partially correct. Also, doesn't enforce restriction | |
| 2752 * that files be of same type (regular->regular, dir->dir, etc). | |
| 2753 */ | |
| 2754 | |
| 621 | 2755 #ifndef HAVE_RENAME |
| 2756 | |
| 491 | 2757 rename (from, to) |
|
3842
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
2758 const char *from; |
|
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
2759 const char *to; |
| 491 | 2760 { |
| 2761 if (access (from, 0) == 0) | |
| 2762 { | |
| 2763 unlink (to); | |
| 2764 if (link (from, to) == 0) | |
| 2765 if (unlink (from) == 0) | |
| 2766 return (0); | |
| 2767 } | |
| 2768 return (-1); | |
| 2769 } | |
| 2770 | |
| 621 | 2771 #endif |
| 2772 | |
| 491 | 2773 #ifdef MISSING_UTIMES |
| 2774 | |
| 2775 /* HPUX (among others) sets HAVE_TIMEVAL but does not implement utimes. */ | |
| 2776 | |
| 2777 utimes () | |
| 2778 { | |
| 2779 } | |
| 2780 #endif | |
| 2781 | |
| 2782 #ifdef IRIS_UTIME | |
| 2783 | |
| 2784 /* The IRIS (3.5) has timevals, but uses sys V utime, and doesn't have the | |
| 2785 utimbuf structure defined anywhere but in the man page. */ | |
| 2786 | |
| 2787 struct utimbuf | |
| 2788 { | |
| 2789 long actime; | |
| 2790 long modtime; | |
| 2791 }; | |
| 2792 | |
| 2793 utimes (name, tvp) | |
| 2794 char *name; | |
| 2795 struct timeval tvp[]; | |
| 2796 { | |
| 2797 struct utimbuf utb; | |
| 2798 utb.actime = tvp[0].tv_sec; | |
| 2799 utb.modtime = tvp[1].tv_sec; | |
| 2800 utime (name, &utb); | |
| 2801 } | |
| 2802 #endif /* IRIS_UTIME */ | |
| 2803 | |
| 2804 | |
| 2805 #ifdef HPUX | |
| 2806 #ifndef HAVE_PERROR | |
| 2807 | |
| 2808 /* HPUX curses library references perror, but as far as we know | |
| 2809 it won't be called. Anyway this definition will do for now. */ | |
| 2810 | |
| 2811 perror () | |
| 2812 { | |
| 2813 } | |
| 2814 | |
| 2815 #endif /* not HAVE_PERROR */ | |
| 2816 #endif /* HPUX */ | |
| 2817 | |
| 2818 #ifndef HAVE_DUP2 | |
| 2819 | |
| 2820 /* | |
| 2821 * Emulate BSD dup2. First close newd if it already exists. | |
| 2822 * Then, attempt to dup oldd. If not successful, call dup2 recursively | |
| 2823 * until we are, then close the unsuccessful ones. | |
| 2824 */ | |
| 2825 | |
| 2826 dup2 (oldd, newd) | |
| 2827 int oldd; | |
| 2828 int newd; | |
| 2829 { | |
| 2830 register int fd, ret; | |
| 2831 | |
| 2832 sys_close (newd); | |
| 2833 | |
| 2834 #ifdef F_DUPFD | |
| 2835 fd = fcntl (oldd, F_DUPFD, newd); | |
| 2836 if (fd != newd) | |
| 2837 error ("can't dup2 (%i,%i) : %s", oldd, newd, sys_errlist[errno]); | |
| 2838 #else | |
| 2839 fd = dup (old); | |
| 2840 if (fd == -1) | |
| 2841 return -1; | |
| 2842 if (fd == new) | |
| 2843 return new; | |
| 2844 ret = dup2 (old,new); | |
| 2845 sys_close (fd); | |
| 2846 return ret; | |
| 2847 #endif | |
| 2848 } | |
| 2849 | |
| 2850 #endif /* not HAVE_DUP2 */ | |
| 2851 | |
| 2852 /* | |
| 2853 * Gettimeofday. Simulate as much as possible. Only accurate | |
| 2854 * to nearest second. Emacs doesn't use tzp so ignore it for now. | |
| 2855 * Only needed when subprocesses are defined. | |
| 2856 */ | |
| 2857 | |
| 2858 #ifdef subprocesses | |
| 2859 #ifndef VMS | |
| 2860 #ifndef HAVE_GETTIMEOFDAY | |
| 2861 #ifdef HAVE_TIMEVAL | |
| 2862 | |
| 2863 /* ARGSUSED */ | |
| 2864 gettimeofday (tp, tzp) | |
| 2865 struct timeval *tp; | |
| 2866 struct timezone *tzp; | |
| 2867 { | |
| 2868 extern long time (); | |
| 2869 | |
| 2870 tp->tv_sec = time ((long *)0); | |
| 2871 tp->tv_usec = 0; | |
|
3239
2e4882a32671
(gettimeofday): Don't store in *tzp if tzp is 0.
Richard M. Stallman <rms@gnu.org>
parents:
3157
diff
changeset
|
2872 if (tzp != 0) |
|
2e4882a32671
(gettimeofday): Don't store in *tzp if tzp is 0.
Richard M. Stallman <rms@gnu.org>
parents:
3157
diff
changeset
|
2873 tzp->tz_minuteswest = -1; |
| 491 | 2874 } |
| 2875 | |
| 2876 #endif | |
| 2877 #endif | |
| 2878 #endif | |
| 2879 #endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL && !VMS */ | |
| 2880 | |
| 2881 /* | |
| 2882 * This function will go away as soon as all the stubs fixed. (fnf) | |
| 2883 */ | |
| 2884 | |
| 2885 croak (badfunc) | |
| 2886 char *badfunc; | |
| 2887 { | |
| 2888 printf ("%s not yet implemented\r\n", badfunc); | |
| 2889 reset_sys_modes (); | |
| 2890 exit (1); | |
| 2891 } | |
| 2892 | |
| 2893 #endif /* USG */ | |
| 2894 | |
| 2895 #ifdef DGUX | |
| 2896 | |
| 2897 char *sys_siglist[NSIG + 1] = | |
| 2898 { | |
| 2899 "null signal", /* 0 SIGNULL */ | |
| 2900 "hangup", /* 1 SIGHUP */ | |
| 2901 "interrupt", /* 2 SIGINT */ | |
| 2902 "quit", /* 3 SIGQUIT */ | |
| 2903 "illegal instruction", /* 4 SIGILL */ | |
| 2904 "trace trap", /* 5 SIGTRAP */ | |
| 2905 "abort termination", /* 6 SIGABRT */ | |
| 2906 "SIGEMT", /* 7 SIGEMT */ | |
| 2907 "floating point exception", /* 8 SIGFPE */ | |
| 2908 "kill", /* 9 SIGKILL */ | |
| 2909 "bus error", /* 10 SIGBUS */ | |
| 2910 "segmentation violation", /* 11 SIGSEGV */ | |
| 2911 "bad argument to system call", /* 12 SIGSYS */ | |
| 2912 "write on a pipe with no reader", /* 13 SIGPIPE */ | |
| 2913 "alarm clock", /* 14 SIGALRM */ | |
| 2914 "software termination signal", /* 15 SIGTERM */ | |
| 2915 "user defined signal 1", /* 16 SIGUSR1 */ | |
| 2916 "user defined signal 2", /* 17 SIGUSR2 */ | |
| 2917 "child stopped or terminated", /* 18 SIGCLD */ | |
| 2918 "power-fail restart", /* 19 SIGPWR */ | |
| 2919 "window size changed", /* 20 SIGWINCH */ | |
| 2920 "undefined", /* 21 */ | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
2921 "pollable event occurred", /* 22 SIGPOLL */ |
| 491 | 2922 "sendable stop signal not from tty", /* 23 SIGSTOP */ |
| 2923 "stop signal from tty", /* 24 SIGSTP */ | |
| 2924 "continue a stopped process", /* 25 SIGCONT */ | |
| 2925 "attempted background tty read", /* 26 SIGTTIN */ | |
| 2926 "attempted background tty write", /* 27 SIGTTOU */ | |
| 2927 "undefined", /* 28 */ | |
| 2928 "undefined", /* 29 */ | |
| 2929 "undefined", /* 30 */ | |
| 2930 "undefined", /* 31 */ | |
| 2931 "undefined", /* 32 */ | |
| 2932 "socket (TCP/IP) urgent data arrival", /* 33 SIGURG */ | |
| 2933 "I/O is possible", /* 34 SIGIO */ | |
| 2934 "exceeded cpu time limit", /* 35 SIGXCPU */ | |
| 2935 "exceeded file size limit", /* 36 SIGXFSZ */ | |
| 2936 "virtual time alarm", /* 37 SIGVTALRM */ | |
| 2937 "profiling time alarm", /* 38 SIGPROF */ | |
| 2938 "undefined", /* 39 */ | |
| 2939 "file record locks revoked", /* 40 SIGLOST */ | |
| 2940 "undefined", /* 41 */ | |
| 2941 "undefined", /* 42 */ | |
| 2942 "undefined", /* 43 */ | |
| 2943 "undefined", /* 44 */ | |
| 2944 "undefined", /* 45 */ | |
| 2945 "undefined", /* 46 */ | |
| 2946 "undefined", /* 47 */ | |
| 2947 "undefined", /* 48 */ | |
| 2948 "undefined", /* 49 */ | |
| 2949 "undefined", /* 50 */ | |
| 2950 "undefined", /* 51 */ | |
| 2951 "undefined", /* 52 */ | |
| 2952 "undefined", /* 53 */ | |
| 2953 "undefined", /* 54 */ | |
| 2954 "undefined", /* 55 */ | |
| 2955 "undefined", /* 56 */ | |
| 2956 "undefined", /* 57 */ | |
| 2957 "undefined", /* 58 */ | |
| 2958 "undefined", /* 59 */ | |
| 2959 "undefined", /* 60 */ | |
| 2960 "undefined", /* 61 */ | |
| 2961 "undefined", /* 62 */ | |
| 2962 "undefined", /* 63 */ | |
| 2963 "notification message in mess. queue", /* 64 SIGDGNOTIFY */ | |
| 2964 0 | |
| 2965 }; | |
| 2966 | |
| 2967 #endif /* DGUX */ | |
| 2968 | |
| 2969 /* Directory routines for systems that don't have them. */ | |
| 2970 | |
| 2971 #ifdef SYSV_SYSTEM_DIR | |
| 2972 | |
| 2973 #include <dirent.h> | |
| 2974 | |
|
3797
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2975 #ifndef HAVE_CLOSEDIR |
| 491 | 2976 int |
| 2977 closedir (dirp) | |
| 2978 register DIR *dirp; /* stream from opendir */ | |
| 2979 { | |
| 2980 sys_close (dirp->dd_fd); | |
|
3760
e0be9df19ee1
* sysdep.c (closedir): Don't free directory buffer if it looks
Jim Blandy <jimb@redhat.com>
parents:
3759
diff
changeset
|
2981 |
|
3797
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2982 /* Some systems (like Solaris) allocate the buffer and the DIR all |
|
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2983 in one block. Why in the world are we freeing this ourselves |
|
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2984 anyway? */ |
|
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2985 #if ! (defined (sun) && defined (USG5_4)) |
|
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2986 xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */ |
|
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2987 #endif |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
2988 xfree ((char *) dirp); |
| 491 | 2989 } |
|
3797
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
2990 #endif /* not HAVE_CLOSEDIR */ |
| 491 | 2991 #endif /* SYSV_SYSTEM_DIR */ |
| 2992 | |
| 2993 #ifdef NONSYSTEM_DIR_LIBRARY | |
| 2994 | |
| 2995 DIR * | |
| 2996 opendir (filename) | |
| 2997 char *filename; /* name of directory */ | |
| 2998 { | |
| 2999 register DIR *dirp; /* -> malloc'ed storage */ | |
| 3000 register int fd; /* file descriptor for read */ | |
| 3001 struct stat sbuf; /* result of fstat */ | |
| 3002 | |
| 3003 fd = sys_open (filename, 0); | |
| 3004 if (fd < 0) | |
| 3005 return 0; | |
| 3006 | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3007 BLOCK_INPUT; |
| 491 | 3008 if (fstat (fd, &sbuf) < 0 |
| 3009 || (sbuf.st_mode & S_IFMT) != S_IFDIR | |
| 3010 || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) | |
| 3011 { | |
| 3012 sys_close (fd); | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3013 UNBLOCK_INPUT; |
| 491 | 3014 return 0; /* bad luck today */ |
| 3015 } | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3016 UNBLOCK_INPUT; |
| 491 | 3017 |
| 3018 dirp->dd_fd = fd; | |
| 3019 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ | |
| 3020 | |
| 3021 return dirp; | |
| 3022 } | |
| 3023 | |
| 3024 void | |
| 3025 closedir (dirp) | |
| 3026 register DIR *dirp; /* stream from opendir */ | |
| 3027 { | |
| 3028 sys_close (dirp->dd_fd); | |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3029 xfree ((char *) dirp); |
| 491 | 3030 } |
| 3031 | |
| 3032 | |
| 3033 #ifndef VMS | |
| 3034 #define DIRSIZ 14 | |
| 3035 struct olddir | |
| 3036 { | |
| 3037 ino_t od_ino; /* inode */ | |
| 3038 char od_name[DIRSIZ]; /* filename */ | |
| 3039 }; | |
| 3040 #endif /* not VMS */ | |
| 3041 | |
| 3042 struct direct dir_static; /* simulated directory contents */ | |
| 3043 | |
| 3044 /* ARGUSED */ | |
| 3045 struct direct * | |
| 3046 readdir (dirp) | |
| 3047 register DIR *dirp; /* stream from opendir */ | |
| 3048 { | |
| 3049 #ifndef VMS | |
| 3050 register struct olddir *dp; /* -> directory data */ | |
| 3051 #else /* VMS */ | |
| 3052 register struct dir$_name *dp; /* -> directory data */ | |
| 3053 register struct dir$_version *dv; /* -> version data */ | |
| 3054 #endif /* VMS */ | |
| 3055 | |
| 3056 for (; ;) | |
| 3057 { | |
| 3058 if (dirp->dd_loc >= dirp->dd_size) | |
| 3059 dirp->dd_loc = dirp->dd_size = 0; | |
| 3060 | |
| 3061 if (dirp->dd_size == 0 /* refill buffer */ | |
| 3062 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
| 3063 return 0; | |
| 3064 | |
| 3065 #ifndef VMS | |
| 3066 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; | |
| 3067 dirp->dd_loc += sizeof (struct olddir); | |
| 3068 | |
| 3069 if (dp->od_ino != 0) /* not deleted entry */ | |
| 3070 { | |
| 3071 dir_static.d_ino = dp->od_ino; | |
| 3072 strncpy (dir_static.d_name, dp->od_name, DIRSIZ); | |
| 3073 dir_static.d_name[DIRSIZ] = '\0'; | |
| 3074 dir_static.d_namlen = strlen (dir_static.d_name); | |
| 3075 dir_static.d_reclen = sizeof (struct direct) | |
| 3076 - MAXNAMLEN + 3 | |
| 3077 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
| 3078 return &dir_static; /* -> simulated structure */ | |
| 3079 } | |
| 3080 #else /* VMS */ | |
| 3081 dp = (struct dir$_name *) dirp->dd_buf; | |
| 3082 if (dirp->dd_loc == 0) | |
| 3083 dirp->dd_loc = (dp->dir$b_namecount&1) ? dp->dir$b_namecount + 1 | |
| 3084 : dp->dir$b_namecount; | |
| 3085 dv = (struct dir$_version *)&dp->dir$t_name[dirp->dd_loc]; | |
| 3086 dir_static.d_ino = dv->dir$w_fid_num; | |
| 3087 dir_static.d_namlen = dp->dir$b_namecount; | |
| 3088 dir_static.d_reclen = sizeof (struct direct) | |
| 3089 - MAXNAMLEN + 3 | |
| 3090 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
| 3091 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
| 3092 dir_static.d_name[dir_static.d_namlen] = '\0'; | |
| 3093 dirp->dd_loc = dirp->dd_size; /* only one record at a time */ | |
| 3094 return &dir_static; | |
| 3095 #endif /* VMS */ | |
| 3096 } | |
| 3097 } | |
| 3098 | |
| 3099 #ifdef VMS | |
| 3100 /* readdirver is just like readdir except it returns all versions of a file | |
| 3101 as separate entries. */ | |
| 3102 | |
| 3103 /* ARGUSED */ | |
| 3104 struct direct * | |
| 3105 readdirver (dirp) | |
| 3106 register DIR *dirp; /* stream from opendir */ | |
| 3107 { | |
| 3108 register struct dir$_name *dp; /* -> directory data */ | |
| 3109 register struct dir$_version *dv; /* -> version data */ | |
| 3110 | |
| 3111 if (dirp->dd_loc >= dirp->dd_size - sizeof (struct dir$_name)) | |
| 3112 dirp->dd_loc = dirp->dd_size = 0; | |
| 3113 | |
| 3114 if (dirp->dd_size == 0 /* refill buffer */ | |
| 3115 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
| 3116 return 0; | |
| 3117 | |
| 3118 dp = (struct dir$_name *) dirp->dd_buf; | |
| 3119 if (dirp->dd_loc == 0) | |
| 3120 dirp->dd_loc = (dp->dir$b_namecount & 1) ? dp->dir$b_namecount + 1 | |
| 3121 : dp->dir$b_namecount; | |
| 3122 dv = (struct dir$_version *) &dp->dir$t_name[dirp->dd_loc]; | |
| 3123 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
| 3124 sprintf (&dir_static.d_name[dp->dir$b_namecount], ";%d", dv->dir$w_version); | |
| 3125 dir_static.d_namlen = strlen (dir_static.d_name); | |
| 3126 dir_static.d_ino = dv->dir$w_fid_num; | |
| 3127 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 | |
| 3128 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
| 3129 dirp->dd_loc = ((char *) (++dv) - dp->dir$t_name); | |
| 3130 return &dir_static; | |
| 3131 } | |
| 3132 | |
| 3133 #endif /* VMS */ | |
| 3134 | |
| 3135 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3136 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3137 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3138 /* mkdir and rmdir functions, for systems which don't have them. */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3139 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3140 #ifndef HAVE_MKDIR |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3141 /* |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3142 * Written by Robert Rother, Mariah Corporation, August 1985. |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3143 * |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3144 * If you want it, it's yours. All I ask in return is that if you |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3145 * figure out how to do this in a Bourne Shell script you send me |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3146 * a copy. |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3147 * sdcsvax!rmr or rmr@uscd |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3148 * |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3149 * Severely hacked over by John Gilmore to make a 4.2BSD compatible |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3150 * subroutine. 11Mar86; hoptoad!gnu |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3151 * |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3152 * Modified by rmtodd@uokmax 6-28-87 -- when making an already existing dir, |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3153 * subroutine didn't return EEXIST. It does now. |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3154 */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3155 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3156 /* |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3157 * Make a directory. |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3158 */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3159 int |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3160 mkdir (dpath, dmode) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3161 char *dpath; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3162 int dmode; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3163 { |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3164 int cpid, status, fd; |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3165 struct stat statbuf; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3166 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3167 if (stat (dpath, &statbuf) == 0) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3168 { |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3169 errno = EEXIST; /* Stat worked, so it already exists */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3170 return -1; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3171 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3172 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3173 /* If stat fails for a reason other than non-existence, return error */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3174 if (errno != ENOENT) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3175 return -1; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3176 |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3177 synch_process_alive = 1; |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3178 switch (cpid = fork ()) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3179 { |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3180 |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3181 case -1: /* Error in fork */ |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3182 return (-1); /* Errno is set already */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3183 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3184 case 0: /* Child process */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3185 /* |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3186 * Cheap hack to set mode of new directory. Since this |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3187 * child process is going away anyway, we zap its umask. |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3188 * FIXME, this won't suffice to set SUID, SGID, etc. on this |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3189 * directory. Does anybody care? |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3190 */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3191 status = umask (0); /* Get current umask */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3192 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3193 fd = sys_open("/dev/null", 2); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3194 if (fd >= 0) |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3195 { |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3196 dup2 (fd, 0); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3197 dup2 (fd, 1); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3198 dup2 (fd, 2); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3199 } |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3200 execl ("/bin/mkdir", "mkdir", dpath, (char *) 0); |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3201 _exit (-1); /* Can't exec /bin/mkdir */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3202 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3203 default: /* Parent process */ |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3204 wait_for_termination (cpid); |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3205 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3206 |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3207 if (synch_process_death != 0 || synch_process_retcode != 0) |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3208 { |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3209 errno = EIO; /* We don't know why, but */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3210 return -1; /* /bin/mkdir failed */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3211 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3212 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3213 return 0; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3214 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3215 #endif /* not HAVE_MKDIR */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3216 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3217 #ifndef HAVE_RMDIR |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3218 int |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3219 rmdir (dpath) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3220 char *dpath; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3221 { |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3222 int cpid, status, fd; |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3223 struct stat statbuf; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3224 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3225 if (stat (dpath, &statbuf) != 0) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3226 { |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3227 /* Stat just set errno. We don't have to */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3228 return -1; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3229 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3230 |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3231 synch_process_alive = 1; |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3232 switch (cpid = fork ()) |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3233 { |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3234 |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3235 case -1: /* Error in fork */ |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3236 return (-1); /* Errno is set already */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3237 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3238 case 0: /* Child process */ |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3239 fd = sys_open("/dev/null", 2); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3240 if (fd >= 0) |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3241 { |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3242 dup2 (fd, 0); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3243 dup2 (fd, 1); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3244 dup2 (fd, 2); |
|
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3245 } |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3246 execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3247 _exit (-1); /* Can't exec /bin/mkdir */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3248 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3249 default: /* Parent process */ |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3250 wait_for_termination (cpid); |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3251 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3252 |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3253 if (synch_process_death != 0 || synch_process_retcode != 0) |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3254 { |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3255 errno = EIO; /* We don't know why, but */ |
|
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3256 return -1; /* /bin/rmdir failed */ |
|
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3257 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3258 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3259 return 0; |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3260 } |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3261 #endif /* !HAVE_RMDIR */ |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3262 |
|
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3263 |
| 491 | 3264 |
| 3265 /* Functions for VMS */ | |
| 3266 #ifdef VMS | |
| 579 | 3267 #include "vms-pwd.h" |
| 491 | 3268 #include <acldef.h> |
| 3269 #include <chpdef.h> | |
| 3270 #include <jpidef.h> | |
| 3271 | |
| 3272 /* Return as a string the VMS error string pertaining to STATUS. | |
| 3273 Reuses the same static buffer each time it is called. */ | |
| 3274 | |
| 3275 char * | |
| 3276 vmserrstr (status) | |
| 3277 int status; /* VMS status code */ | |
| 3278 { | |
| 3279 int bufadr[2]; | |
| 3280 short len; | |
| 3281 static char buf[257]; | |
| 3282 | |
| 3283 bufadr[0] = sizeof buf - 1; | |
| 3284 bufadr[1] = (int) buf; | |
| 3285 if (! (SYS$GETMSG (status, &len, bufadr, 0x1, 0) & 1)) | |
| 3286 return "untranslatable VMS error status"; | |
| 3287 buf[len] = '\0'; | |
| 3288 return buf; | |
| 3289 } | |
| 3290 | |
| 3291 #ifdef access | |
| 3292 #undef access | |
| 3293 | |
| 3294 /* The following is necessary because 'access' emulation by VMS C (2.0) does | |
| 3295 * not work correctly. (It also doesn't work well in version 2.3.) | |
| 3296 */ | |
| 3297 | |
| 3298 #ifdef VMS4_4 | |
| 3299 | |
| 3300 #define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \ | |
| 3301 { strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string } | |
| 3302 | |
| 3303 typedef union { | |
| 3304 struct { | |
| 3305 unsigned short s_buflen; | |
| 3306 unsigned short s_code; | |
| 3307 char *s_bufadr; | |
| 3308 unsigned short *s_retlenadr; | |
| 3309 } s; | |
| 3310 int end; | |
| 3311 } item; | |
| 3312 #define buflen s.s_buflen | |
| 3313 #define code s.s_code | |
| 3314 #define bufadr s.s_bufadr | |
| 3315 #define retlenadr s.s_retlenadr | |
| 3316 | |
| 3317 #define R_OK 4 /* test for read permission */ | |
| 3318 #define W_OK 2 /* test for write permission */ | |
| 3319 #define X_OK 1 /* test for execute (search) permission */ | |
| 3320 #define F_OK 0 /* test for presence of file */ | |
| 3321 | |
| 3322 int | |
| 3323 sys_access (path, mode) | |
| 3324 char *path; | |
| 3325 int mode; | |
| 3326 { | |
| 3327 static char *user = NULL; | |
| 3328 char dir_fn[512]; | |
| 3329 | |
| 3330 /* translate possible directory spec into .DIR file name, so brain-dead | |
| 3331 * access can treat the directory like a file. */ | |
| 3332 if (directory_file_name (path, dir_fn)) | |
| 3333 path = dir_fn; | |
| 3334 | |
| 3335 if (mode == F_OK) | |
| 3336 return access (path, mode); | |
| 3337 if (user == NULL && (user = (char *) getenv ("USER")) == NULL) | |
| 3338 return -1; | |
| 3339 { | |
| 3340 int stat; | |
| 3341 int flags; | |
| 3342 int acces; | |
| 3343 unsigned short int dummy; | |
| 3344 item itemlst[3]; | |
| 3345 static int constant = ACL$C_FILE; | |
| 3346 DESCRIPTOR (path_desc, path); | |
| 3347 DESCRIPTOR (user_desc, user); | |
| 3348 | |
| 3349 flags = 0; | |
| 3350 acces = 0; | |
| 3351 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK)) | |
| 3352 return stat; | |
| 3353 if (mode & R_OK) | |
| 3354 acces |= CHP$M_READ; | |
| 3355 if (mode & W_OK) | |
| 3356 acces |= CHP$M_WRITE; | |
| 3357 itemlst[0].buflen = sizeof (int); | |
| 3358 itemlst[0].code = CHP$_FLAGS; | |
| 3359 itemlst[0].bufadr = (char *) &flags; | |
| 3360 itemlst[0].retlenadr = &dummy; | |
| 3361 itemlst[1].buflen = sizeof (int); | |
| 3362 itemlst[1].code = CHP$_ACCESS; | |
| 3363 itemlst[1].bufadr = (char *) &acces; | |
| 3364 itemlst[1].retlenadr = &dummy; | |
| 3365 itemlst[2].end = CHP$_END; | |
| 3366 stat = SYS$CHECK_ACCESS (&constant, &path_desc, &user_desc, itemlst); | |
| 3367 return stat == SS$_NORMAL ? 0 : -1; | |
| 3368 } | |
| 3369 } | |
| 3370 | |
| 3371 #else /* not VMS4_4 */ | |
| 3372 | |
| 3373 #include <prvdef.h> | |
| 3374 #define ACE$M_WRITE 2 | |
| 3375 #define ACE$C_KEYID 1 | |
| 3376 | |
| 3377 static unsigned short memid, grpid; | |
| 3378 static unsigned int uic; | |
| 3379 | |
| 3380 /* Called from init_sys_modes, so it happens not very often | |
| 3381 but at least each time Emacs is loaded. */ | |
| 3382 sys_access_reinit () | |
| 3383 { | |
| 3384 uic = 0; | |
| 3385 } | |
| 3386 | |
| 3387 int | |
| 3388 sys_access (filename, type) | |
| 3389 char * filename; | |
| 3390 int type; | |
| 3391 { | |
| 3392 struct FAB fab; | |
| 3393 struct XABPRO xab; | |
| 3394 int status, size, i, typecode, acl_controlled; | |
| 3395 unsigned int *aclptr, *aclend, aclbuf[60]; | |
| 3396 union prvdef prvmask; | |
| 3397 | |
| 3398 /* Get UIC and GRP values for protection checking. */ | |
| 3399 if (uic == 0) | |
| 3400 { | |
| 3401 status = LIB$GETJPI (&JPI$_UIC, 0, 0, &uic, 0, 0); | |
| 3402 if (! (status & 1)) | |
| 3403 return -1; | |
| 3404 memid = uic & 0xFFFF; | |
| 3405 grpid = uic >> 16; | |
| 3406 } | |
| 3407 | |
| 3408 if (type != 2) /* not checking write access */ | |
| 3409 return access (filename, type); | |
| 3410 | |
| 3411 /* Check write protection. */ | |
| 3412 | |
| 3413 #define CHECKPRIV(bit) (prvmask.bit) | |
| 3414 #define WRITEABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) | |
| 3415 | |
| 3416 /* Find privilege bits */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3417 status = SYS$SETPRV (0, 0, 0, prvmask); |
| 491 | 3418 if (! (status & 1)) |
| 3419 error ("Unable to find privileges: %s", vmserrstr (status)); | |
| 3420 if (CHECKPRIV (PRV$V_BYPASS)) | |
| 3421 return 0; /* BYPASS enabled */ | |
| 3422 fab = cc$rms_fab; | |
| 3423 fab.fab$b_fac = FAB$M_GET; | |
| 3424 fab.fab$l_fna = filename; | |
| 3425 fab.fab$b_fns = strlen (filename); | |
| 3426 fab.fab$l_xab = &xab; | |
| 3427 xab = cc$rms_xabpro; | |
| 3428 xab.xab$l_aclbuf = aclbuf; | |
| 3429 xab.xab$w_aclsiz = sizeof (aclbuf); | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3430 status = SYS$OPEN (&fab, 0, 0); |
| 491 | 3431 if (! (status & 1)) |
| 3432 return -1; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3433 SYS$CLOSE (&fab, 0, 0); |
| 491 | 3434 /* Check system access */ |
| 3435 if (CHECKPRIV (PRV$V_SYSPRV) && WRITEABLE (XAB$V_SYS)) | |
| 3436 return 0; | |
| 3437 /* Check ACL entries, if any */ | |
| 3438 acl_controlled = 0; | |
| 3439 if (xab.xab$w_acllen > 0) | |
| 3440 { | |
| 3441 aclptr = aclbuf; | |
| 3442 aclend = &aclbuf[xab.xab$w_acllen / 4]; | |
| 3443 while (*aclptr && aclptr < aclend) | |
| 3444 { | |
| 3445 size = (*aclptr & 0xff) / 4; | |
| 3446 typecode = (*aclptr >> 8) & 0xff; | |
| 3447 if (typecode == ACE$C_KEYID) | |
| 3448 for (i = size - 1; i > 1; i--) | |
| 3449 if (aclptr[i] == uic) | |
| 3450 { | |
| 3451 acl_controlled = 1; | |
| 3452 if (aclptr[1] & ACE$M_WRITE) | |
| 3453 return 0; /* Write access through ACL */ | |
| 3454 } | |
| 3455 aclptr = &aclptr[size]; | |
| 3456 } | |
| 3457 if (acl_controlled) /* ACL specified, prohibits write access */ | |
| 3458 return -1; | |
| 3459 } | |
| 3460 /* No ACL entries specified, check normal protection */ | |
| 3461 if (WRITEABLE (XAB$V_WLD)) /* World writeable */ | |
| 3462 return 0; | |
| 3463 if (WRITEABLE (XAB$V_GRP) && | |
| 3464 (unsigned short) (xab.xab$l_uic >> 16) == grpid) | |
| 3465 return 0; /* Group writeable */ | |
| 3466 if (WRITEABLE (XAB$V_OWN) && | |
| 3467 (xab.xab$l_uic & 0xFFFF) == memid) | |
| 3468 return 0; /* Owner writeable */ | |
| 3469 | |
| 3470 return -1; /* Not writeable */ | |
| 3471 } | |
| 3472 #endif /* not VMS4_4 */ | |
| 3473 #endif /* access */ | |
| 3474 | |
| 3475 static char vtbuf[NAM$C_MAXRSS+1]; | |
| 3476 | |
| 3477 /* translate a vms file spec to a unix path */ | |
| 3478 char * | |
| 3479 sys_translate_vms (vfile) | |
| 3480 char * vfile; | |
| 3481 { | |
| 3482 char * p; | |
| 3483 char * targ; | |
| 3484 | |
| 3485 if (!vfile) | |
| 3486 return 0; | |
| 3487 | |
| 3488 targ = vtbuf; | |
| 3489 | |
| 3490 /* leading device or logical name is a root directory */ | |
| 3491 if (p = strchr (vfile, ':')) | |
| 3492 { | |
| 3493 *targ++ = '/'; | |
| 3494 while (vfile < p) | |
| 3495 *targ++ = *vfile++; | |
| 3496 vfile++; | |
| 3497 *targ++ = '/'; | |
| 3498 } | |
| 3499 p = vfile; | |
| 3500 if (*p == '[' || *p == '<') | |
| 3501 { | |
| 3502 while (*++vfile != *p + 2) | |
| 3503 switch (*vfile) | |
| 3504 { | |
| 3505 case '.': | |
| 3506 if (vfile[-1] == *p) | |
| 3507 *targ++ = '.'; | |
| 3508 *targ++ = '/'; | |
| 3509 break; | |
| 3510 | |
| 3511 case '-': | |
| 3512 *targ++ = '.'; | |
| 3513 *targ++ = '.'; | |
| 3514 break; | |
| 3515 | |
| 3516 default: | |
| 3517 *targ++ = *vfile; | |
| 3518 break; | |
| 3519 } | |
| 3520 vfile++; | |
| 3521 *targ++ = '/'; | |
| 3522 } | |
| 3523 while (*vfile) | |
| 3524 *targ++ = *vfile++; | |
| 3525 | |
| 3526 return vtbuf; | |
| 3527 } | |
| 3528 | |
| 3529 static char utbuf[NAM$C_MAXRSS+1]; | |
| 3530 | |
| 3531 /* translate a unix path to a VMS file spec */ | |
| 3532 char * | |
| 3533 sys_translate_unix (ufile) | |
| 3534 char * ufile; | |
| 3535 { | |
| 3536 int slash_seen = 0; | |
| 3537 char *p; | |
| 3538 char * targ; | |
| 3539 | |
| 3540 if (!ufile) | |
| 3541 return 0; | |
| 3542 | |
| 3543 targ = utbuf; | |
| 3544 | |
| 3545 if (*ufile == '/') | |
| 3546 { | |
| 3547 ufile++; | |
| 3548 } | |
| 3549 | |
| 3550 while (*ufile) | |
| 3551 { | |
| 3552 switch (*ufile) | |
| 3553 { | |
| 3554 case '/': | |
| 3555 if (slash_seen) | |
| 3556 if (index (&ufile[1], '/')) | |
| 3557 *targ++ = '.'; | |
| 3558 else | |
| 3559 *targ++ = ']'; | |
| 3560 else | |
| 3561 { | |
| 3562 *targ++ = ':'; | |
| 3563 if (index (&ufile[1], '/')) | |
| 3564 *targ++ = '['; | |
| 3565 slash_seen = 1; | |
| 3566 } | |
| 3567 break; | |
| 3568 | |
| 3569 case '.': | |
| 3570 if (strncmp (ufile, "./", 2) == 0) | |
| 3571 { | |
| 3572 if (!slash_seen) | |
| 3573 { | |
| 3574 *targ++ = '['; | |
| 3575 slash_seen = 1; | |
| 3576 } | |
| 3577 ufile++; /* skip the dot */ | |
| 3578 if (index (&ufile[1], '/')) | |
| 3579 *targ++ = '.'; | |
| 3580 else | |
| 3581 *targ++ = ']'; | |
| 3582 } | |
| 3583 else if (strncmp (ufile, "../", 3) == 0) | |
| 3584 { | |
| 3585 if (!slash_seen) | |
| 3586 { | |
| 3587 *targ++ = '['; | |
| 3588 slash_seen = 1; | |
| 3589 } | |
| 3590 *targ++ = '-'; | |
| 3591 ufile += 2; /* skip the dots */ | |
| 3592 if (index (&ufile[1], '/')) | |
| 3593 *targ++ = '.'; | |
| 3594 else | |
| 3595 *targ++ = ']'; | |
| 3596 } | |
| 3597 else | |
| 3598 *targ++ = *ufile; | |
| 3599 break; | |
| 3600 | |
| 3601 default: | |
| 3602 *targ++ = *ufile; | |
| 3603 break; | |
| 3604 } | |
| 3605 ufile++; | |
| 3606 } | |
| 3607 *targ = '\0'; | |
| 3608 | |
| 3609 return utbuf; | |
| 3610 } | |
| 3611 | |
| 3612 char * | |
| 3613 getwd (pathname) | |
| 3614 char *pathname; | |
| 3615 { | |
| 3616 char *ptr; | |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3617 extern char *getcwd (); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3618 |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3619 #define MAXPATHLEN 1024 |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3620 |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3621 ptr = xmalloc (MAXPATHLEN); |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3622 getcwd (ptr, MAXPATHLEN); |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3623 strcpy (pathname, ptr); |
|
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3624 xfree (ptr); |
|
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3625 |
|
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
3626 return pathname; |
| 491 | 3627 } |
| 3628 | |
| 3629 getppid () | |
| 3630 { | |
| 3631 long item_code = JPI$_OWNER; | |
| 3632 unsigned long parent_id; | |
| 3633 int status; | |
| 3634 | |
| 3635 if (((status = LIB$GETJPI (&item_code, 0, 0, &parent_id)) & 1) == 0) | |
| 3636 { | |
| 3637 errno = EVMSERR; | |
| 3638 vaxc$errno = status; | |
| 3639 return -1; | |
| 3640 } | |
| 3641 return parent_id; | |
| 3642 } | |
| 3643 | |
| 3644 #undef getuid | |
| 3645 unsigned | |
| 3646 sys_getuid () | |
| 3647 { | |
| 3648 return (getgid () << 16) | getuid (); | |
| 3649 } | |
| 3650 | |
| 3651 int | |
| 3652 sys_read (fildes, buf, nbyte) | |
| 3653 int fildes; | |
| 3654 char *buf; | |
| 3655 unsigned int nbyte; | |
| 3656 { | |
| 3657 return read (fildes, buf, (nbyte < MAXIOSIZE ? nbyte : MAXIOSIZE)); | |
| 3658 } | |
| 3659 | |
| 3660 #if 0 | |
| 3661 int | |
| 3662 sys_write (fildes, buf, nbyte) | |
| 3663 int fildes; | |
| 3664 char *buf; | |
| 3665 unsigned int nbyte; | |
| 3666 { | |
| 3667 register int nwrote, rtnval = 0; | |
| 3668 | |
| 3669 while (nbyte > MAXIOSIZE && (nwrote = write (fildes, buf, MAXIOSIZE)) > 0) { | |
| 3670 nbyte -= nwrote; | |
| 3671 buf += nwrote; | |
| 3672 rtnval += nwrote; | |
| 3673 } | |
| 3674 if (nwrote < 0) | |
| 3675 return rtnval ? rtnval : -1; | |
| 3676 if ((nwrote = write (fildes, buf, nbyte)) < 0) | |
| 3677 return rtnval ? rtnval : -1; | |
| 3678 return (rtnval + nwrote); | |
| 3679 } | |
| 3680 #endif /* 0 */ | |
| 3681 | |
| 3682 /* | |
| 3683 * VAX/VMS VAX C RTL really loses. It insists that records | |
| 3684 * end with a newline (carriage return) character, and if they | |
| 3685 * don't it adds one (nice of it isn't it!) | |
| 3686 * | |
| 3687 * Thus we do this stupidity below. | |
| 3688 */ | |
| 3689 | |
| 3690 int | |
| 3691 sys_write (fildes, buf, nbytes) | |
| 3692 int fildes; | |
| 3693 char *buf; | |
| 3694 unsigned int nbytes; | |
| 3695 { | |
| 3696 register char *p; | |
| 3697 register char *e; | |
| 525 | 3698 int sum = 0; |
| 3699 struct stat st; | |
| 3700 | |
| 3701 fstat (fildes, &st); | |
| 491 | 3702 p = buf; |
| 3703 while (nbytes > 0) | |
| 3704 { | |
| 525 | 3705 int len, retval; |
| 3706 | |
| 3707 /* Handle fixed-length files with carriage control. */ | |
| 3708 if (st.st_fab_rfm == FAB$C_FIX | |
| 3709 && ((st.st_fab_rat & (FAB$M_FTN | FAB$M_CR)) != 0)) | |
| 3710 { | |
| 3711 len = st.st_fab_mrs; | |
| 3712 retval = write (fildes, p, min (len, nbytes)); | |
| 3713 if (retval != len) | |
| 3714 return -1; | |
| 3715 retval++; /* This skips the implied carriage control */ | |
| 3716 } | |
| 3717 else | |
| 3718 { | |
| 3719 e = p + min (MAXIOSIZE, nbytes) - 1; | |
| 3720 while (*e != '\n' && e > p) e--; | |
| 3721 if (p == e) /* Ok.. so here we add a newline... sigh. */ | |
| 3722 e = p + min (MAXIOSIZE, nbytes) - 1; | |
| 3723 len = e + 1 - p; | |
| 3724 retval = write (fildes, p, len); | |
| 3725 if (retval != len) | |
| 3726 return -1; | |
| 3727 } | |
| 3728 p += retval; | |
| 3729 sum += retval; | |
| 491 | 3730 nbytes -= retval; |
| 3731 } | |
| 3732 return sum; | |
| 3733 } | |
| 3734 | |
| 3735 /* Create file NEW copying its attributes from file OLD. If | |
| 3736 OLD is 0 or does not exist, create based on the value of | |
| 3737 vms_stmlf_recfm. */ | |
| 3738 | |
| 3739 /* Protection value the file should ultimately have. | |
| 3740 Set by create_copy_attrs, and use by rename_sansversions. */ | |
| 3741 static unsigned short int fab_final_pro; | |
| 3742 | |
| 3743 int | |
| 3744 creat_copy_attrs (old, new) | |
| 3745 char *old, *new; | |
| 3746 { | |
| 3747 struct FAB fab = cc$rms_fab; | |
| 3748 struct XABPRO xabpro; | |
| 3749 char aclbuf[256]; /* Choice of size is arbitrary. See below. */ | |
| 3750 extern int vms_stmlf_recfm; | |
| 3751 | |
| 3752 if (old) | |
| 3753 { | |
| 3754 fab.fab$b_fac = FAB$M_GET; | |
| 3755 fab.fab$l_fna = old; | |
| 3756 fab.fab$b_fns = strlen (old); | |
| 3757 fab.fab$l_xab = (char *) &xabpro; | |
| 3758 xabpro = cc$rms_xabpro; | |
| 3759 xabpro.xab$l_aclbuf = aclbuf; | |
| 3760 xabpro.xab$w_aclsiz = sizeof aclbuf; | |
| 3761 /* Call $OPEN to fill in the fab & xabpro fields. */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3762 if (SYS$OPEN (&fab, 0, 0) & 1) |
| 491 | 3763 { |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3764 SYS$CLOSE (&fab, 0, 0); |
| 491 | 3765 fab.fab$l_alq = 0; /* zero the allocation quantity */ |
| 3766 if (xabpro.xab$w_acllen > 0) | |
| 3767 { | |
| 3768 if (xabpro.xab$w_acllen > sizeof aclbuf) | |
| 3769 /* If the acl buffer was too short, redo open with longer one. | |
| 3770 Wouldn't need to do this if there were some system imposed | |
| 3771 limit on the size of an ACL, but I can't find any such. */ | |
| 3772 { | |
| 3773 xabpro.xab$l_aclbuf = (char *) alloca (xabpro.xab$w_acllen); | |
| 3774 xabpro.xab$w_aclsiz = xabpro.xab$w_acllen; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3775 if (SYS$OPEN (&fab, 0, 0) & 1) |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3776 SYS$CLOSE (&fab, 0, 0); |
| 491 | 3777 else |
| 3778 old = 0; | |
| 3779 } | |
| 3780 } | |
| 3781 else | |
| 3782 xabpro.xab$l_aclbuf = 0; | |
| 3783 } | |
| 3784 else | |
| 3785 old = 0; | |
| 3786 } | |
| 3787 fab.fab$l_fna = new; | |
| 3788 fab.fab$b_fns = strlen (new); | |
| 3789 if (!old) | |
| 3790 { | |
| 3791 fab.fab$l_xab = 0; | |
| 3792 fab.fab$b_rfm = vms_stmlf_recfm ? FAB$C_STMLF : FAB$C_VAR; | |
| 3793 fab.fab$b_rat = FAB$M_CR; | |
| 3794 } | |
| 3795 | |
| 3796 /* Set the file protections such that we will be able to manipulate | |
| 3797 this file. Once we are done writing and renaming it, we will set | |
| 3798 the protections back. */ | |
| 3799 if (old) | |
| 3800 fab_final_pro = xabpro.xab$w_pro; | |
| 3801 else | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3802 SYS$SETDFPROT (0, &fab_final_pro); |
| 491 | 3803 xabpro.xab$w_pro &= 0xff0f; /* set O:rewd for now. This is set back later. */ |
| 3804 | |
| 3805 /* Create the new file with either default attrs or attrs copied | |
| 3806 from old file. */ | |
| 3807 if (!(SYS$CREATE (&fab, 0, 0) & 1)) | |
| 3808 return -1; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3809 SYS$CLOSE (&fab, 0, 0); |
| 491 | 3810 /* As this is a "replacement" for creat, return a file descriptor |
| 3811 opened for writing. */ | |
| 3812 return open (new, O_WRONLY); | |
| 3813 } | |
| 3814 | |
| 3815 #ifdef creat | |
| 3816 #undef creat | |
| 3817 #include <varargs.h> | |
| 3818 #ifdef __GNUC__ | |
| 3819 #ifndef va_count | |
| 3820 #define va_count(X) ((X) = *(((int *) &(va_alist)) - 1)) | |
| 3821 #endif | |
| 3822 #endif | |
| 3823 | |
| 3824 sys_creat (va_alist) | |
| 3825 va_dcl | |
| 3826 { | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3827 va_list list_incrementer; |
| 491 | 3828 char *name; |
| 3829 int mode; | |
| 3830 int rfd; /* related file descriptor */ | |
| 3831 int fd; /* Our new file descriptor */ | |
| 3832 int count; | |
| 3833 struct stat st_buf; | |
| 3834 char rfm[12]; | |
| 3835 char rat[15]; | |
| 3836 char mrs[13]; | |
| 3837 char fsz[13]; | |
| 3838 extern int vms_stmlf_recfm; | |
| 3839 | |
| 3840 va_count (count); | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3841 va_start (list_incrementer); |
|
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3842 name = va_arg (list_incrementer, char *); |
|
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3843 mode = va_arg (list_incrementer, int); |
| 491 | 3844 if (count > 2) |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3845 rfd = va_arg (list_incrementer, int); |
|
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3846 va_end (list_incrementer); |
| 491 | 3847 if (count > 2) |
| 3848 { | |
| 3849 /* Use information from the related file descriptor to set record | |
| 3850 format of the newly created file. */ | |
| 3851 fstat (rfd, &st_buf); | |
| 3852 switch (st_buf.st_fab_rfm) | |
| 3853 { | |
| 3854 case FAB$C_FIX: | |
| 3855 strcpy (rfm, "rfm = fix"); | |
| 3856 sprintf (mrs, "mrs = %d", st_buf.st_fab_mrs); | |
| 3857 strcpy (rat, "rat = "); | |
| 3858 if (st_buf.st_fab_rat & FAB$M_CR) | |
| 3859 strcat (rat, "cr"); | |
| 3860 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
| 3861 strcat (rat, "ftn"); | |
| 3862 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
| 3863 strcat (rat, "prn"); | |
| 3864 if (st_buf.st_fab_rat & FAB$M_BLK) | |
| 3865 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
| 3866 strcat (rat, ", blk"); | |
| 3867 else | |
| 3868 strcat (rat, "blk"); | |
| 3869 return creat (name, 0, rfm, rat, mrs); | |
| 3870 | |
| 3871 case FAB$C_VFC: | |
| 3872 strcpy (rfm, "rfm = vfc"); | |
| 3873 sprintf (fsz, "fsz = %d", st_buf.st_fab_fsz); | |
| 3874 strcpy (rat, "rat = "); | |
| 3875 if (st_buf.st_fab_rat & FAB$M_CR) | |
| 3876 strcat (rat, "cr"); | |
| 3877 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
| 3878 strcat (rat, "ftn"); | |
| 3879 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
| 3880 strcat (rat, "prn"); | |
| 3881 if (st_buf.st_fab_rat & FAB$M_BLK) | |
| 3882 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
| 3883 strcat (rat, ", blk"); | |
| 3884 else | |
| 3885 strcat (rat, "blk"); | |
| 3886 return creat (name, 0, rfm, rat, fsz); | |
| 3887 | |
| 3888 case FAB$C_STM: | |
| 3889 strcpy (rfm, "rfm = stm"); | |
| 3890 break; | |
| 3891 | |
| 3892 case FAB$C_STMCR: | |
| 3893 strcpy (rfm, "rfm = stmcr"); | |
| 3894 break; | |
| 3895 | |
| 3896 case FAB$C_STMLF: | |
| 3897 strcpy (rfm, "rfm = stmlf"); | |
| 3898 break; | |
| 3899 | |
| 3900 case FAB$C_UDF: | |
| 3901 strcpy (rfm, "rfm = udf"); | |
| 3902 break; | |
| 3903 | |
| 3904 case FAB$C_VAR: | |
| 3905 strcpy (rfm, "rfm = var"); | |
| 3906 break; | |
| 3907 } | |
| 3908 strcpy (rat, "rat = "); | |
| 3909 if (st_buf.st_fab_rat & FAB$M_CR) | |
| 3910 strcat (rat, "cr"); | |
| 3911 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
| 3912 strcat (rat, "ftn"); | |
| 3913 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
| 3914 strcat (rat, "prn"); | |
| 3915 if (st_buf.st_fab_rat & FAB$M_BLK) | |
| 3916 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
| 3917 strcat (rat, ", blk"); | |
| 3918 else | |
| 3919 strcat (rat, "blk"); | |
| 3920 } | |
| 3921 else | |
| 3922 { | |
| 3923 strcpy (rfm, vms_stmlf_recfm ? "rfm = stmlf" : "rfm=var"); | |
| 3924 strcpy (rat, "rat=cr"); | |
| 3925 } | |
| 3926 /* Until the VAX C RTL fixes the many bugs with modes, always use | |
| 3927 mode 0 to get the user's default protection. */ | |
| 3928 fd = creat (name, 0, rfm, rat); | |
| 3929 if (fd < 0 && errno == EEXIST) | |
| 3930 { | |
| 3931 if (unlink (name) < 0) | |
| 3932 report_file_error ("delete", build_string (name)); | |
| 3933 fd = creat (name, 0, rfm, rat); | |
| 3934 } | |
| 3935 return fd; | |
| 3936 } | |
| 3937 #endif /* creat */ | |
| 3938 | |
| 3939 /* fwrite to stdout is S L O W. Speed it up by using fputc...*/ | |
| 3940 sys_fwrite (ptr, size, num, fp) | |
| 3941 register char * ptr; | |
| 3942 FILE * fp; | |
| 3943 { | |
| 3944 register int tot = num * size; | |
| 3945 | |
| 3946 while (tot--) | |
| 3947 fputc (*ptr++, fp); | |
| 3948 } | |
| 3949 | |
| 3950 /* | |
| 3951 * The VMS C library routine creat actually creates a new version of an | |
| 3952 * existing file rather than truncating the old version. There are times | |
| 3953 * when this is not the desired behavior, for instance, when writing an | |
| 3954 * auto save file (you only want one version), or when you don't have | |
| 3955 * write permission in the directory containing the file (but the file | |
| 3956 * itself is writable). Hence this routine, which is equivalent to | |
| 3957 * "close (creat (fn, 0));" on Unix if fn already exists. | |
| 3958 */ | |
| 3959 int | |
| 3960 vms_truncate (fn) | |
| 3961 char *fn; | |
| 3962 { | |
| 3963 struct FAB xfab = cc$rms_fab; | |
| 3964 struct RAB xrab = cc$rms_rab; | |
| 3965 int status; | |
| 3966 | |
| 3967 xfab.fab$l_fop = FAB$M_TEF; /* free allocated but unused blocks on close */ | |
| 3968 xfab.fab$b_fac = FAB$M_TRN | FAB$M_GET; /* allow truncate and get access */ | |
| 3969 xfab.fab$b_shr = FAB$M_NIL; /* allow no sharing - file must be locked */ | |
| 3970 xfab.fab$l_fna = fn; | |
| 3971 xfab.fab$b_fns = strlen (fn); | |
| 3972 xfab.fab$l_dna = ";0"; /* default to latest version of the file */ | |
| 3973 xfab.fab$b_dns = 2; | |
| 3974 xrab.rab$l_fab = &xfab; | |
| 3975 | |
| 3976 /* This gibberish opens the file, positions to the first record, and | |
| 3977 deletes all records from there until the end of file. */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3978 if ((SYS$OPEN (&xfab) & 01) == 01) |
| 491 | 3979 { |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3980 if ((SYS$CONNECT (&xrab) & 01) == 01 && |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3981 (SYS$FIND (&xrab) & 01) == 01 && |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3982 (SYS$TRUNCATE (&xrab) & 01) == 01) |
| 491 | 3983 status = 0; |
| 3984 else | |
| 3985 status = -1; | |
| 3986 } | |
| 3987 else | |
| 3988 status = -1; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
3989 SYS$CLOSE (&xfab); |
| 491 | 3990 return status; |
| 3991 } | |
| 3992 | |
| 3993 /* Define this symbol to actually read SYSUAF.DAT. This requires either | |
| 3994 SYSPRV or a readable SYSUAF.DAT. */ | |
| 3995 | |
| 3996 #ifdef READ_SYSUAF | |
| 3997 /* | |
| 3998 * getuaf.c | |
| 3999 * | |
| 4000 * Routine to read the VMS User Authorization File and return | |
| 4001 * a specific user's record. | |
| 4002 */ | |
| 4003 | |
| 4004 static struct UAF retuaf; | |
| 4005 | |
| 4006 struct UAF * | |
| 4007 get_uaf_name (uname) | |
| 4008 char * uname; | |
| 4009 { | |
| 4010 register status; | |
| 4011 struct FAB uaf_fab; | |
| 4012 struct RAB uaf_rab; | |
| 4013 | |
| 4014 uaf_fab = cc$rms_fab; | |
| 4015 uaf_rab = cc$rms_rab; | |
| 4016 /* initialize fab fields */ | |
| 4017 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
| 4018 uaf_fab.fab$b_fns = 21; | |
| 4019 uaf_fab.fab$b_fac = FAB$M_GET; | |
| 4020 uaf_fab.fab$b_org = FAB$C_IDX; | |
| 4021 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
| 4022 /* initialize rab fields */ | |
| 4023 uaf_rab.rab$l_fab = &uaf_fab; | |
| 4024 /* open the User Authorization File */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4025 status = SYS$OPEN (&uaf_fab); |
| 491 | 4026 if (!(status&1)) |
| 4027 { | |
| 4028 errno = EVMSERR; | |
| 4029 vaxc$errno = status; | |
| 4030 return 0; | |
| 4031 } | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4032 status = SYS$CONNECT (&uaf_rab); |
| 491 | 4033 if (!(status&1)) |
| 4034 { | |
| 4035 errno = EVMSERR; | |
| 4036 vaxc$errno = status; | |
| 4037 return 0; | |
| 4038 } | |
| 4039 /* read the requested record - index is in uname */ | |
| 4040 uaf_rab.rab$l_kbf = uname; | |
| 4041 uaf_rab.rab$b_ksz = strlen (uname); | |
| 4042 uaf_rab.rab$b_rac = RAB$C_KEY; | |
| 4043 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
| 4044 uaf_rab.rab$w_usz = sizeof retuaf; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4045 status = SYS$GET (&uaf_rab); |
| 491 | 4046 if (!(status&1)) |
| 4047 { | |
| 4048 errno = EVMSERR; | |
| 4049 vaxc$errno = status; | |
| 4050 return 0; | |
| 4051 } | |
| 4052 /* close the User Authorization File */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4053 status = SYS$DISCONNECT (&uaf_rab); |
| 491 | 4054 if (!(status&1)) |
| 4055 { | |
| 4056 errno = EVMSERR; | |
| 4057 vaxc$errno = status; | |
| 4058 return 0; | |
| 4059 } | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4060 status = SYS$CLOSE (&uaf_fab); |
| 491 | 4061 if (!(status&1)) |
| 4062 { | |
| 4063 errno = EVMSERR; | |
| 4064 vaxc$errno = status; | |
| 4065 return 0; | |
| 4066 } | |
| 4067 return &retuaf; | |
| 4068 } | |
| 4069 | |
| 4070 struct UAF * | |
| 4071 get_uaf_uic (uic) | |
| 4072 unsigned long uic; | |
| 4073 { | |
| 4074 register status; | |
| 4075 struct FAB uaf_fab; | |
| 4076 struct RAB uaf_rab; | |
| 4077 | |
| 4078 uaf_fab = cc$rms_fab; | |
| 4079 uaf_rab = cc$rms_rab; | |
| 4080 /* initialize fab fields */ | |
| 4081 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
| 4082 uaf_fab.fab$b_fns = 21; | |
| 4083 uaf_fab.fab$b_fac = FAB$M_GET; | |
| 4084 uaf_fab.fab$b_org = FAB$C_IDX; | |
| 4085 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
| 4086 /* initialize rab fields */ | |
| 4087 uaf_rab.rab$l_fab = &uaf_fab; | |
| 4088 /* open the User Authorization File */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4089 status = SYS$OPEN (&uaf_fab); |
| 491 | 4090 if (!(status&1)) |
| 4091 { | |
| 4092 errno = EVMSERR; | |
| 4093 vaxc$errno = status; | |
| 4094 return 0; | |
| 4095 } | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4096 status = SYS$CONNECT (&uaf_rab); |
| 491 | 4097 if (!(status&1)) |
| 4098 { | |
| 4099 errno = EVMSERR; | |
| 4100 vaxc$errno = status; | |
| 4101 return 0; | |
| 4102 } | |
| 4103 /* read the requested record - index is in uic */ | |
| 4104 uaf_rab.rab$b_krf = 1; /* 1st alternate key */ | |
| 4105 uaf_rab.rab$l_kbf = (char *) &uic; | |
| 4106 uaf_rab.rab$b_ksz = sizeof uic; | |
| 4107 uaf_rab.rab$b_rac = RAB$C_KEY; | |
| 4108 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
| 4109 uaf_rab.rab$w_usz = sizeof retuaf; | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4110 status = SYS$GET (&uaf_rab); |
| 491 | 4111 if (!(status&1)) |
| 4112 { | |
| 4113 errno = EVMSERR; | |
| 4114 vaxc$errno = status; | |
| 4115 return 0; | |
| 4116 } | |
| 4117 /* close the User Authorization File */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4118 status = SYS$DISCONNECT (&uaf_rab); |
| 491 | 4119 if (!(status&1)) |
| 4120 { | |
| 4121 errno = EVMSERR; | |
| 4122 vaxc$errno = status; | |
| 4123 return 0; | |
| 4124 } | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4125 status = SYS$CLOSE (&uaf_fab); |
| 491 | 4126 if (!(status&1)) |
| 4127 { | |
| 4128 errno = EVMSERR; | |
| 4129 vaxc$errno = status; | |
| 4130 return 0; | |
| 4131 } | |
| 4132 return &retuaf; | |
| 4133 } | |
| 4134 | |
| 4135 static struct passwd retpw; | |
| 4136 | |
| 4137 struct passwd * | |
| 4138 cnv_uaf_pw (up) | |
| 4139 struct UAF * up; | |
| 4140 { | |
| 4141 char * ptr; | |
| 4142 | |
| 4143 /* copy these out first because if the username is 32 chars, the next | |
| 4144 section will overwrite the first byte of the UIC */ | |
| 4145 retpw.pw_uid = up->uaf$w_mem; | |
| 4146 retpw.pw_gid = up->uaf$w_grp; | |
| 4147 | |
| 4148 /* I suppose this is not the best sytle, to possibly overwrite one | |
| 4149 byte beyond the end of the field, but what the heck... */ | |
| 4150 ptr = &up->uaf$t_username[UAF$S_USERNAME]; | |
| 4151 while (ptr[-1] == ' ') | |
| 4152 ptr--; | |
| 4153 *ptr = '\0'; | |
| 4154 strcpy (retpw.pw_name, up->uaf$t_username); | |
| 4155 | |
| 4156 /* the rest of these are counted ascii strings */ | |
| 4157 strncpy (retpw.pw_gecos, &up->uaf$t_owner[1], up->uaf$t_owner[0]); | |
| 4158 retpw.pw_gecos[up->uaf$t_owner[0]] = '\0'; | |
| 4159 strncpy (retpw.pw_dir, &up->uaf$t_defdev[1], up->uaf$t_defdev[0]); | |
| 4160 retpw.pw_dir[up->uaf$t_defdev[0]] = '\0'; | |
| 4161 strncat (retpw.pw_dir, &up->uaf$t_defdir[1], up->uaf$t_defdir[0]); | |
| 4162 retpw.pw_dir[up->uaf$t_defdev[0] + up->uaf$t_defdir[0]] = '\0'; | |
| 4163 strncpy (retpw.pw_shell, &up->uaf$t_defcli[1], up->uaf$t_defcli[0]); | |
| 4164 retpw.pw_shell[up->uaf$t_defcli[0]] = '\0'; | |
| 4165 | |
| 4166 return &retpw; | |
| 4167 } | |
| 4168 #else /* not READ_SYSUAF */ | |
| 4169 static struct passwd retpw; | |
| 4170 #endif /* not READ_SYSUAF */ | |
| 4171 | |
| 4172 struct passwd * | |
| 4173 getpwnam (name) | |
| 4174 char * name; | |
| 4175 { | |
| 4176 #ifdef READ_SYSUAF | |
| 4177 struct UAF *up; | |
| 4178 #else | |
| 4179 char * user; | |
| 4180 char * dir; | |
| 4181 unsigned char * full; | |
| 4182 #endif /* READ_SYSUAF */ | |
| 4183 char *ptr = name; | |
| 4184 | |
| 4185 while (*ptr) | |
| 4186 { | |
| 4187 if ('a' <= *ptr && *ptr <= 'z') | |
| 4188 *ptr -= 040; | |
| 4189 ptr++; | |
| 4190 } | |
| 4191 #ifdef READ_SYSUAF | |
| 4192 if (!(up = get_uaf_name (name))) | |
| 4193 return 0; | |
| 4194 return cnv_uaf_pw (up); | |
| 4195 #else | |
| 4196 if (strcmp (name, getenv ("USER")) == 0) | |
| 4197 { | |
| 4198 retpw.pw_uid = getuid (); | |
| 4199 retpw.pw_gid = getgid (); | |
| 4200 strcpy (retpw.pw_name, name); | |
| 4201 if (full = egetenv ("FULLNAME")) | |
| 4202 strcpy (retpw.pw_gecos, full); | |
| 4203 else | |
| 4204 *retpw.pw_gecos = '\0'; | |
| 4205 strcpy (retpw.pw_dir, egetenv ("HOME")); | |
| 4206 *retpw.pw_shell = '\0'; | |
| 4207 return &retpw; | |
| 4208 } | |
| 4209 else | |
| 4210 return 0; | |
| 4211 #endif /* not READ_SYSUAF */ | |
| 4212 } | |
| 4213 | |
| 4214 struct passwd * | |
| 4215 getpwuid (uid) | |
| 4216 unsigned long uid; | |
| 4217 { | |
| 4218 #ifdef READ_SYSUAF | |
| 4219 struct UAF * up; | |
| 4220 | |
| 4221 if (!(up = get_uaf_uic (uid))) | |
| 4222 return 0; | |
| 4223 return cnv_uaf_pw (up); | |
| 4224 #else | |
| 4225 if (uid == sys_getuid ()) | |
| 4226 return getpwnam (egetenv ("USER")); | |
| 4227 else | |
| 4228 return 0; | |
| 4229 #endif /* not READ_SYSUAF */ | |
| 4230 } | |
| 4231 | |
| 4232 /* return total address space available to the current process. This is | |
| 4233 the sum of the current p0 size, p1 size and free page table entries | |
| 4234 available. */ | |
| 4235 vlimit () | |
| 4236 { | |
| 4237 int item_code; | |
| 4238 unsigned long free_pages; | |
| 4239 unsigned long frep0va; | |
| 4240 unsigned long frep1va; | |
| 4241 register status; | |
| 4242 | |
| 4243 item_code = JPI$_FREPTECNT; | |
| 4244 if (((status = LIB$GETJPI (&item_code, 0, 0, &free_pages)) & 1) == 0) | |
| 4245 { | |
| 4246 errno = EVMSERR; | |
| 4247 vaxc$errno = status; | |
| 4248 return -1; | |
| 4249 } | |
| 4250 free_pages *= 512; | |
| 4251 | |
| 4252 item_code = JPI$_FREP0VA; | |
| 4253 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep0va)) & 1) == 0) | |
| 4254 { | |
| 4255 errno = EVMSERR; | |
| 4256 vaxc$errno = status; | |
| 4257 return -1; | |
| 4258 } | |
| 4259 item_code = JPI$_FREP1VA; | |
| 4260 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep1va)) & 1) == 0) | |
| 4261 { | |
| 4262 errno = EVMSERR; | |
| 4263 vaxc$errno = status; | |
| 4264 return -1; | |
| 4265 } | |
| 4266 | |
| 4267 return free_pages + frep0va + (0x7fffffff - frep1va); | |
| 4268 } | |
| 4269 | |
| 4270 define_logical_name (varname, string) | |
| 4271 char *varname; | |
| 4272 char *string; | |
| 4273 { | |
| 4274 struct dsc$descriptor_s strdsc = | |
| 4275 {strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string}; | |
| 4276 struct dsc$descriptor_s envdsc = | |
| 4277 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
| 4278 struct dsc$descriptor_s lnmdsc = | |
| 4279 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
| 4280 | |
| 4281 return LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0); | |
| 4282 } | |
| 4283 | |
| 4284 delete_logical_name (varname) | |
| 4285 char *varname; | |
| 4286 { | |
| 4287 struct dsc$descriptor_s envdsc = | |
| 4288 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
| 4289 struct dsc$descriptor_s lnmdsc = | |
| 4290 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
| 4291 | |
| 4292 return LIB$DELETE_LOGICAL (&envdsc, &lnmdsc); | |
| 4293 } | |
| 4294 | |
| 4295 ulimit () | |
| 4296 {} | |
| 4297 | |
| 4298 setpgrp () | |
| 4299 {} | |
| 4300 | |
| 4301 execvp () | |
| 4302 { | |
| 4303 error ("execvp system call not implemented"); | |
| 4304 } | |
| 4305 | |
| 4306 int | |
| 4307 rename (from, to) | |
| 4308 char *from, *to; | |
| 4309 { | |
| 4310 int status; | |
| 4311 struct FAB from_fab = cc$rms_fab, to_fab = cc$rms_fab; | |
| 4312 struct NAM from_nam = cc$rms_nam, to_nam = cc$rms_nam; | |
| 4313 char from_esn[NAM$C_MAXRSS]; | |
| 4314 char to_esn[NAM$C_MAXRSS]; | |
| 4315 | |
| 4316 from_fab.fab$l_fna = from; | |
| 4317 from_fab.fab$b_fns = strlen (from); | |
| 4318 from_fab.fab$l_nam = &from_nam; | |
| 4319 from_fab.fab$l_fop = FAB$M_NAM; | |
| 4320 | |
| 4321 from_nam.nam$l_esa = from_esn; | |
| 4322 from_nam.nam$b_ess = sizeof from_esn; | |
| 4323 | |
| 4324 to_fab.fab$l_fna = to; | |
| 4325 to_fab.fab$b_fns = strlen (to); | |
| 4326 to_fab.fab$l_nam = &to_nam; | |
| 4327 to_fab.fab$l_fop = FAB$M_NAM; | |
| 4328 | |
| 4329 to_nam.nam$l_esa = to_esn; | |
| 4330 to_nam.nam$b_ess = sizeof to_esn; | |
| 4331 | |
| 4332 status = SYS$RENAME (&from_fab, 0, 0, &to_fab); | |
| 4333 | |
| 4334 if (status & 1) | |
| 4335 return 0; | |
| 4336 else | |
| 4337 { | |
| 4338 if (status == RMS$_DEV) | |
| 4339 errno = EXDEV; | |
| 4340 else | |
| 4341 errno = EVMSERR; | |
| 4342 vaxc$errno = status; | |
| 4343 return -1; | |
| 4344 } | |
| 4345 } | |
| 4346 | |
| 4347 /* This function renames a file like `rename', but it strips | |
| 4348 the version number from the "to" filename, such that the "to" file is | |
| 4349 will always be a new version. It also sets the file protection once it is | |
| 4350 finished. The protection that we will use is stored in fab_final_pro, | |
| 4351 and was set when we did a creat_copy_attrs to create the file that we | |
| 4352 are renaming. | |
| 4353 | |
| 4354 We could use the chmod function, but Eunichs uses 3 bits per user category | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4355 to describe the protection, and VMS uses 4 (write and delete are separate |
| 491 | 4356 bits). To maintain portability, the VMS implementation of `chmod' wires |
| 4357 the W and D bits together. */ | |
| 4358 | |
| 4359 | |
| 4360 static struct fibdef fib; /* We need this initialized to zero */ | |
| 4361 char vms_file_written[NAM$C_MAXRSS]; | |
| 4362 | |
| 4363 int | |
| 4364 rename_sans_version (from,to) | |
| 4365 char *from, *to; | |
| 4366 { | |
| 4367 short int chan; | |
| 4368 int stat; | |
| 4369 short int iosb[4]; | |
| 4370 int status; | |
| 4371 struct FAB to_fab = cc$rms_fab; | |
| 4372 struct NAM to_nam = cc$rms_nam; | |
| 4373 struct dsc$descriptor fib_d ={sizeof (fib),0,0,(char*) &fib}; | |
| 4374 struct dsc$descriptor fib_attr[2] | |
| 4375 = {{sizeof (fab_final_pro),ATR$C_FPRO,0,(char*) &fab_final_pro},{0,0,0,0}}; | |
| 4376 char to_esn[NAM$C_MAXRSS]; | |
| 4377 | |
| 4378 $DESCRIPTOR (disk,to_esn); | |
| 4379 | |
| 4380 to_fab.fab$l_fna = to; | |
| 4381 to_fab.fab$b_fns = strlen (to); | |
| 4382 to_fab.fab$l_nam = &to_nam; | |
| 4383 to_fab.fab$l_fop = FAB$M_NAM; | |
| 4384 | |
| 4385 to_nam.nam$l_esa = to_esn; | |
| 4386 to_nam.nam$b_ess = sizeof to_esn; | |
| 4387 | |
| 4388 status = SYS$PARSE (&to_fab, 0, 0); /* figure out the full file name */ | |
| 4389 | |
| 4390 if (to_nam.nam$l_fnb && NAM$M_EXP_VER) | |
| 4391 *(to_nam.nam$l_ver) = '\0'; | |
| 4392 | |
| 4393 stat = rename (from, to_esn); | |
| 4394 if (stat < 0) | |
| 4395 return stat; | |
| 4396 | |
| 4397 strcpy (vms_file_written, to_esn); | |
| 4398 | |
| 4399 to_fab.fab$l_fna = vms_file_written; /* this points to the versionless name */ | |
| 4400 to_fab.fab$b_fns = strlen (vms_file_written); | |
| 4401 | |
| 4402 /* Now set the file protection to the correct value */ | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4403 SYS$OPEN (&to_fab, 0, 0); /* This fills in the nam$w_fid fields */ |
| 491 | 4404 |
| 4405 /* Copy these fields into the fib */ | |
| 4406 fib.fib$r_fid_overlay.fib$w_fid[0] = to_nam.nam$w_fid[0]; | |
| 4407 fib.fib$r_fid_overlay.fib$w_fid[1] = to_nam.nam$w_fid[1]; | |
| 4408 fib.fib$r_fid_overlay.fib$w_fid[2] = to_nam.nam$w_fid[2]; | |
| 4409 | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4410 SYS$CLOSE (&to_fab, 0, 0); |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4411 |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4412 stat = SYS$ASSIGN (&disk, &chan, 0, 0); /* open a channel to the disk */ |
| 491 | 4413 if (!stat) |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4414 LIB$SIGNAL (stat); |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4415 stat = SYS$QIOW (0, chan, IO$_MODIFY, iosb, 0, 0, &fib_d, |
| 491 | 4416 0, 0, 0, &fib_attr, 0); |
| 4417 if (!stat) | |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4418 LIB$SIGNAL (stat); |
|
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4419 stat = SYS$DASSGN (chan); |
| 491 | 4420 if (!stat) |
|
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4421 LIB$SIGNAL (stat); |
| 766 | 4422 strcpy (vms_file_written, to_esn); /* We will write this to the terminal*/ |
| 491 | 4423 return 0; |
| 4424 } | |
| 4425 | |
| 4426 link (file, new) | |
| 4427 char * file, * new; | |
| 4428 { | |
| 4429 register status; | |
| 4430 struct FAB fab; | |
| 4431 struct NAM nam; | |
| 4432 unsigned short fid[3]; | |
| 4433 char esa[NAM$C_MAXRSS]; | |
| 4434 | |
| 4435 fab = cc$rms_fab; | |
| 4436 fab.fab$l_fop = FAB$M_OFP; | |
| 4437 fab.fab$l_fna = file; | |
| 4438 fab.fab$b_fns = strlen (file); | |
| 4439 fab.fab$l_nam = &nam; | |
| 4440 | |
| 4441 nam = cc$rms_nam; | |
| 4442 nam.nam$l_esa = esa; | |
| 4443 nam.nam$b_ess = NAM$C_MAXRSS; | |
| 4444 | |
| 4445 status = SYS$PARSE (&fab); | |
| 4446 if ((status & 1) == 0) | |
| 4447 { | |
| 4448 errno = EVMSERR; | |
| 4449 vaxc$errno = status; | |
| 4450 return -1; | |
| 4451 } | |
| 4452 status = SYS$SEARCH (&fab); | |
| 4453 if ((status & 1) == 0) | |
| 4454 { | |
| 4455 errno = EVMSERR; | |
| 4456 vaxc$errno = status; | |
| 4457 return -1; | |
| 4458 } | |
| 4459 | |
| 4460 fid[0] = nam.nam$w_fid[0]; | |
| 4461 fid[1] = nam.nam$w_fid[1]; | |
| 4462 fid[2] = nam.nam$w_fid[2]; | |
| 4463 | |
| 4464 fab.fab$l_fna = new; | |
| 4465 fab.fab$b_fns = strlen (new); | |
| 4466 | |
| 4467 status = SYS$PARSE (&fab); | |
| 4468 if ((status & 1) == 0) | |
| 4469 { | |
| 4470 errno = EVMSERR; | |
| 4471 vaxc$errno = status; | |
| 4472 return -1; | |
| 4473 } | |
| 4474 | |
| 4475 nam.nam$w_fid[0] = fid[0]; | |
| 4476 nam.nam$w_fid[1] = fid[1]; | |
| 4477 nam.nam$w_fid[2] = fid[2]; | |
| 4478 | |
| 4479 nam.nam$l_esa = nam.nam$l_name; | |
| 4480 nam.nam$b_esl = nam.nam$b_name + nam.nam$b_type + nam.nam$b_ver; | |
| 4481 | |
| 4482 status = SYS$ENTER (&fab); | |
| 4483 if ((status & 1) == 0) | |
| 4484 { | |
| 4485 errno = EVMSERR; | |
| 4486 vaxc$errno = status; | |
| 4487 return -1; | |
| 4488 } | |
| 4489 | |
| 4490 return 0; | |
| 4491 } | |
| 4492 | |
| 4493 croak (badfunc) | |
| 4494 char *badfunc; | |
| 4495 { | |
| 4496 printf ("%s not yet implemented\r\n", badfunc); | |
| 4497 reset_sys_modes (); | |
| 4498 exit (1); | |
| 4499 } | |
| 4500 | |
| 4501 long | |
| 4502 random () | |
| 4503 { | |
| 4504 /* Arrange to return a range centered on zero. */ | |
| 4505 return rand () - (1 << 30); | |
| 4506 } | |
| 4507 | |
| 4508 srandom (seed) | |
| 4509 { | |
| 4510 srand (seed); | |
| 4511 } | |
| 4512 #endif /* VMS */ | |
| 4513 | |
| 4514 #ifdef AIX | |
| 4515 | |
| 4516 /* Called from init_sys_modes. */ | |
| 4517 hft_init () | |
| 4518 { | |
| 4519 int junk; | |
| 4520 | |
| 4521 /* If we're not on an HFT we shouldn't do any of this. We determine | |
| 4522 if we are on an HFT by trying to get an HFT error code. If this | |
| 4523 call fails, we're not on an HFT. */ | |
| 4524 #ifdef IBMR2AIX | |
| 4525 if (ioctl (0, HFQERROR, &junk) < 0) | |
| 4526 return; | |
| 4527 #else /* not IBMR2AIX */ | |
| 4528 if (ioctl (0, HFQEIO, 0) < 0) | |
| 4529 return; | |
| 4530 #endif /* not IBMR2AIX */ | |
| 4531 | |
| 4532 /* On AIX the default hft keyboard mapping uses backspace rather than delete | |
| 4533 as the rubout key's ASCII code. Here this is changed. The bug is that | |
| 4534 there's no way to determine the old mapping, so in reset_sys_modes | |
| 4535 we need to assume that the normal map had been present. Of course, this | |
| 4536 code also doesn't help if on a terminal emulator which doesn't understand | |
| 4537 HFT VTD's. */ | |
| 4538 { | |
| 4539 struct hfbuf buf; | |
| 4540 struct hfkeymap keymap; | |
| 4541 | |
| 4542 buf.hf_bufp = (char *)&keymap; | |
| 4543 buf.hf_buflen = sizeof (keymap); | |
| 4544 keymap.hf_nkeys = 2; | |
| 4545 keymap.hfkey[0].hf_kpos = 15; | |
| 4546 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
| 4547 #ifdef IBMR2AIX | |
| 4548 keymap.hfkey[0].hf_keyidh = '<'; | |
| 4549 #else /* not IBMR2AIX */ | |
| 4550 keymap.hfkey[0].hf_page = '<'; | |
| 4551 #endif /* not IBMR2AIX */ | |
| 4552 keymap.hfkey[0].hf_char = 127; | |
| 4553 keymap.hfkey[1].hf_kpos = 15; | |
| 4554 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
| 4555 #ifdef IBMR2AIX | |
| 4556 keymap.hfkey[1].hf_keyidh = '<'; | |
| 4557 #else /* not IBMR2AIX */ | |
| 4558 keymap.hfkey[1].hf_page = '<'; | |
| 4559 #endif /* not IBMR2AIX */ | |
| 4560 keymap.hfkey[1].hf_char = 127; | |
| 4561 hftctl (0, HFSKBD, &buf); | |
| 4562 } | |
| 4563 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly | |
| 4564 at times. */ | |
| 4565 line_ins_del_ok = char_ins_del_ok = 0; | |
| 4566 } | |
| 4567 | |
| 4568 /* Reset the rubout key to backspace. */ | |
| 4569 | |
| 4570 hft_reset () | |
| 4571 { | |
| 4572 struct hfbuf buf; | |
| 4573 struct hfkeymap keymap; | |
| 4574 int junk; | |
| 4575 | |
| 4576 #ifdef IBMR2AIX | |
| 4577 if (ioctl (0, HFQERROR, &junk) < 0) | |
| 4578 return; | |
| 4579 #else /* not IBMR2AIX */ | |
| 4580 if (ioctl (0, HFQEIO, 0) < 0) | |
| 4581 return; | |
| 4582 #endif /* not IBMR2AIX */ | |
| 4583 | |
| 4584 buf.hf_bufp = (char *)&keymap; | |
| 4585 buf.hf_buflen = sizeof (keymap); | |
| 4586 keymap.hf_nkeys = 2; | |
| 4587 keymap.hfkey[0].hf_kpos = 15; | |
| 4588 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
| 4589 #ifdef IBMR2AIX | |
| 4590 keymap.hfkey[0].hf_keyidh = '<'; | |
| 4591 #else /* not IBMR2AIX */ | |
| 4592 keymap.hfkey[0].hf_page = '<'; | |
| 4593 #endif /* not IBMR2AIX */ | |
| 4594 keymap.hfkey[0].hf_char = 8; | |
| 4595 keymap.hfkey[1].hf_kpos = 15; | |
| 4596 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
| 4597 #ifdef IBMR2AIX | |
| 4598 keymap.hfkey[1].hf_keyidh = '<'; | |
| 4599 #else /* not IBMR2AIX */ | |
| 4600 keymap.hfkey[1].hf_page = '<'; | |
| 4601 #endif /* not IBMR2AIX */ | |
| 4602 keymap.hfkey[1].hf_char = 8; | |
| 4603 hftctl (0, HFSKBD, &buf); | |
| 4604 } | |
| 4605 | |
| 4606 #endif /* AIX */ |
