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