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