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