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