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