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