Mercurial > emacs
annotate src/sysdep.c @ 83032:b8237c556f0e
Fix the case when emacsclient is run on Emacs's controlling tty.
src/term.c (O_NOCTTY): Make sure it's defined.
(no_controlling_tty): New variable.
(init_initial_display, mark_ttys): Remove unused variable.
(term_init): Check that the given filename is a terminal device.
Dissociate the controlling terminal if we reopen it for other purposes.
(Reported by Dan Nicolaescu <dann at ics dot uci dot edu>.
(Fdelete_tty): Return nil.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-72
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 02 Feb 2004 22:09:56 +0000 |
parents | 1d2f73785d9d |
children | fcf6fc349e0d |
rev | line source |
---|---|
491 | 1 /* Interfaces to system-dependent kernel and library entries. |
51572
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2 Copyright (C) 1985, 86,87,88,93,94,95,1999,2000,01,2003 |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
3 Free Software Foundation, Inc. |
491 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 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
|
9 the Free Software Foundation; either version 2, or (at your option) |
491 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 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
|
19 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
|
20 Boston, MA 02111-1307, USA. */ |
491 | 21 |
42469 | 22 #ifdef HAVE_CONFIG_H |
23 #include <config.h> | |
24 #endif | |
25 | |
491 | 26 #include <signal.h> |
27 #include <setjmp.h> | |
29387
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
28 #ifdef HAVE_UNISTD_H |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
29 #include <unistd.h> |
2ead157165c4
Conditionally include stdlib.h, unistd.h.
Dave Love <fx@gnu.org>
parents:
29252
diff
changeset
|
30 #endif |
491 | 31 #include "lisp.h" |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
32 /* Including stdlib.h isn't necessarily enough to get srandom |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
33 declared, e.g. without __USE_XOPEN_EXTENDED with glibc 2. */ |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
34 #ifdef HAVE_RANDOM |
35189 | 35 #if 0 /* It turns out that defining _OSF_SOURCE in osf5-0.h gets |
36 random prototyped as returning `int'. It looks to me as | |
37 though the best way to DTRT is to prefer the rand48 functions | |
38 (per libc.info). -- fx */ | |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
39 extern long int random P_ ((void)); |
35189 | 40 #endif |
35077
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
41 #if 0 /* Don't prototype srandom; it takes an unsigned argument on |
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
42 some systems, and an unsigned long on others, like FreeBSD |
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
43 4.1. */ |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
44 extern void srandom P_ ((unsigned int)); |
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
45 #endif |
35077
ef98c2544bee
Don't prototype srandom; it takes an unsigned argument
Gerd Moellmann <gerd@gnu.org>
parents:
35055
diff
changeset
|
46 #endif |
35055
daf01616a3e7
(random, srandom): Declare explicitly.
Dave Love <fx@gnu.org>
parents:
33718
diff
changeset
|
47 |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
48 #include "sysselect.h" |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
49 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
50 #include "blockinput.h" |
491 | 51 #undef NULL |
52 | |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44099
diff
changeset
|
53 #ifdef MAC_OS8 |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
54 /* It is essential to include stdlib.h so that this file picks up |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
55 the correct definitions of rand, srand, and RAND_MAX. |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
56 Otherwise random numbers will not work correctly. */ |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
57 #include <stdlib.h> |
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
58 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
59 #ifndef subprocesses |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
60 /* Nonzero means delete a process right away if it exits (process.c). */ |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
61 static int delete_exited_processes; |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
62 #endif |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44099
diff
changeset
|
63 #endif /* MAC_OS8 */ |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
64 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
65 #ifdef WINDOWSNT |
27933
ea5807a5d84e
[WINDOWSNT]: Use sys_read and sys_write to ensure correct line-ending
Jason Rumney <jasonr@gnu.org>
parents:
27922
diff
changeset
|
66 #define read sys_read |
ea5807a5d84e
[WINDOWSNT]: Use sys_read and sys_write to ensure correct line-ending
Jason Rumney <jasonr@gnu.org>
parents:
27922
diff
changeset
|
67 #define write sys_write |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
68 #include <windows.h> |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
69 #ifndef NULL |
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
70 #define NULL 0 |
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
71 #endif |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
72 #endif /* not WINDOWSNT */ |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
73 |
48741
a7aee9fdf21e
Have emacs_read use sys_read on carbon/Mac OS X
Steven Tamm <steventamm@mac.com>
parents:
48652
diff
changeset
|
74 #ifdef HAVE_CARBON |
a7aee9fdf21e
Have emacs_read use sys_read on carbon/Mac OS X
Steven Tamm <steventamm@mac.com>
parents:
48652
diff
changeset
|
75 #define read sys_read |
a7aee9fdf21e
Have emacs_read use sys_read on carbon/Mac OS X
Steven Tamm <steventamm@mac.com>
parents:
48652
diff
changeset
|
76 #endif |
a7aee9fdf21e
Have emacs_read use sys_read on carbon/Mac OS X
Steven Tamm <steventamm@mac.com>
parents:
48652
diff
changeset
|
77 |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
78 /* 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
|
79 #ifndef fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
80 #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
|
81 #else |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
82 #undef fwrite |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
83 #endif |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
84 |
491 | 85 #include <stdio.h> |
86 #include <sys/types.h> | |
87 #include <sys/stat.h> | |
88 #include <errno.h> | |
89 | |
29125
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
90 #ifdef HAVE_SETPGID |
29150
0398ec3316c5
(setpgrp): Don't define if USG and BSD_PGRPS are not defined.
Gerd Moellmann <gerd@gnu.org>
parents:
29125
diff
changeset
|
91 #if !defined (USG) || defined (BSD_PGRPS) |
29911
02b0c6c15f1c
Undefine setpgrp before setting it.
Dave Love <fx@gnu.org>
parents:
29812
diff
changeset
|
92 #undef setpgrp |
29125
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
93 #define setpgrp setpgid |
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
94 #endif |
29150
0398ec3316c5
(setpgrp): Don't define if USG and BSD_PGRPS are not defined.
Gerd Moellmann <gerd@gnu.org>
parents:
29125
diff
changeset
|
95 #endif |
29125
63520d6017fb
(setpgrp) [HAVE_SETPGID]: Define as setpgid.
Gerd Moellmann <gerd@gnu.org>
parents:
29033
diff
changeset
|
96 |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
97 /* Get SI_SRPC_DOMAIN, if it is available. */ |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
98 #ifdef HAVE_SYS_SYSTEMINFO_H |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
99 #include <sys/systeminfo.h> |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
100 #endif |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
101 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
102 #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
|
103 #include <dos.h> |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
104 #include "dosfns.h" |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
105 #include "msdos.h" |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
106 #include <sys/param.h> |
14971
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
107 |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
108 #if __DJGPP__ > 1 |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
109 extern int etext; |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
110 extern unsigned start __asm__ ("start"); |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
111 #endif |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
112 #endif |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
113 |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
114 #ifndef USE_CRT_DLL |
25453
61fb4dde8684
Include <stdlib.h> if available. Declare errno only if it is not a macro.
Andreas Schwab <schwab@suse.de>
parents:
25431
diff
changeset
|
115 #ifndef errno |
491 | 116 extern int errno; |
25453
61fb4dde8684
Include <stdlib.h> if available. Declare errno only if it is not a macro.
Andreas Schwab <schwab@suse.de>
parents:
25431
diff
changeset
|
117 #endif |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
118 #endif |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
119 |
5533
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
120 #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
|
121 #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
|
122 #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
|
123 #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
|
124 #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
|
125 #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
|
126 #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
|
127 #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
|
128 #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
|
129 #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
|
130 #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
|
131 #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
|
132 #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
|
133 #else |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
134 #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
|
135 #endif |
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
136 #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
|
137 #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
|
138 #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
|
139 #endif |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
140 #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
|
141 #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
|
142 |
46922
ee04d07683ab
[!VMS]: Include sys/files.h.
Richard M. Stallman <rms@gnu.org>
parents:
46653
diff
changeset
|
143 #ifndef VMS |
ee04d07683ab
[!VMS]: Include sys/files.h.
Richard M. Stallman <rms@gnu.org>
parents:
46653
diff
changeset
|
144 #include <sys/file.h> |
ee04d07683ab
[!VMS]: Include sys/files.h.
Richard M. Stallman <rms@gnu.org>
parents:
46653
diff
changeset
|
145 #endif /* not VMS */ |
ee04d07683ab
[!VMS]: Include sys/files.h.
Richard M. Stallman <rms@gnu.org>
parents:
46653
diff
changeset
|
146 |
48652
682129896be4
(fcntl.h): Test only HAVE_FCNTL_H.
Richard M. Stallman <rms@gnu.org>
parents:
48507
diff
changeset
|
147 #ifdef HAVE_FCNTL_H |
5533
cabacc65710f
Restore big block of #ifdef and #include lines for fcntl.h and friends,
Roland McGrath <roland@gnu.org>
parents:
5518
diff
changeset
|
148 #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
|
149 #endif |
491 | 150 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
151 #ifndef MSDOS |
491 | 152 #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
|
153 #endif |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
154 |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
155 #include "systty.h" |
4640 | 156 #include "syswait.h" |
491 | 157 |
158 #ifdef BROKEN_TIOCGWINSZ | |
159 #undef TIOCGWINSZ | |
7559
c786925f32a5
[BROKEN_TIOCGWINSZ]: Undef TIOCSWINSZ too.
Richard M. Stallman <rms@gnu.org>
parents:
7482
diff
changeset
|
160 #undef TIOCSWINSZ |
491 | 161 #endif |
162 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
163 #if defined (USG) || defined (DGUX) |
491 | 164 #include <sys/utsname.h> |
165 #ifndef MEMORY_IN_STRING_H | |
166 #include <memory.h> | |
167 #endif | |
7326
f6e5ef4a73e3
Test ISC4_0 along with TIOCGWINSZ.
Richard M. Stallman <rms@gnu.org>
parents:
6895
diff
changeset
|
168 #if defined (TIOCGWINSZ) || defined (ISC4_0) |
491 | 169 #ifdef NEED_SIOCTL |
170 #include <sys/sioctl.h> | |
171 #endif | |
172 #ifdef NEED_PTEM_H | |
173 #include <sys/stream.h> | |
174 #include <sys/ptem.h> | |
175 #endif | |
7326
f6e5ef4a73e3
Test ISC4_0 along with TIOCGWINSZ.
Richard M. Stallman <rms@gnu.org>
parents:
6895
diff
changeset
|
176 #endif /* TIOCGWINSZ or ISC4_0 */ |
20288 | 177 #endif /* USG or DGUX */ |
491 | 178 |
179 extern int quit_char; | |
180 | |
31101
1a4f15527382
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30611
diff
changeset
|
181 #include "keyboard.h" |
766 | 182 #include "frame.h" |
491 | 183 #include "window.h" |
184 #include "termhooks.h" | |
185 #include "termchar.h" | |
186 #include "termopts.h" | |
187 #include "dispextern.h" | |
188 #include "process.h" | |
53341 | 189 #include "cm.h" /* for reset_sys_modes */ |
491 | 190 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
191 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
192 #include <direct.h> |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
193 /* 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
|
194 #define _P_WAIT 0 |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
195 int _CRTAPI1 _spawnlp (int, const char *, const char *, ...); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
196 int _CRTAPI1 _getpid (void); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
197 #endif |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
198 |
491 | 199 #ifdef NONSYSTEM_DIR_LIBRARY |
200 #include "ndir.h" | |
201 #endif /* NONSYSTEM_DIR_LIBRARY */ | |
202 | |
579 | 203 #include "syssignal.h" |
204 #include "systime.h" | |
9239
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
205 #ifdef HAVE_UTIME_H |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
206 #include <utime.h> |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
207 #endif |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
208 |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
209 #ifndef HAVE_UTIMES |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
210 #ifndef HAVE_STRUCT_UTIMBUF |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
211 /* 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
|
212 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
|
213 struct utimbuf { |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
214 long actime; |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
215 long modtime; |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
216 }; |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
217 #endif |
d4ad53f37cc7
Include <utime.h> here instead of in systime.h.
Karl Heuer <kwzh@gnu.org>
parents:
9110
diff
changeset
|
218 #endif |
491 | 219 |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
220 /* 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
|
221 #ifndef LPASS8 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
222 #define LPASS8 0 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
223 #endif |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
224 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
225 #ifdef BSD4_1 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
226 #define LNOFLSH 0100000 |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
227 #endif |
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
228 |
491 | 229 static int baud_convert[] = |
230 #ifdef BAUD_CONVERT | |
231 BAUD_CONVERT; | |
232 #else | |
233 { | |
234 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, | |
235 1800, 2400, 4800, 9600, 19200, 38400 | |
236 }; | |
237 #endif | |
238 | |
29252
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
239 #ifdef HAVE_SPEED_T |
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
240 #include <termios.h> |
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
241 #else |
19023
f7a3c16c49cb
[HAVE_LIBNCURSES]: Declare ospeed as short, unless NCURSES_OSPEED_T.
Richard M. Stallman <rms@gnu.org>
parents:
18808
diff
changeset
|
242 #if defined (HAVE_LIBNCURSES) && ! defined (NCURSES_OSPEED_T) |
f7a3c16c49cb
[HAVE_LIBNCURSES]: Declare ospeed as short, unless NCURSES_OSPEED_T.
Richard M. Stallman <rms@gnu.org>
parents:
18808
diff
changeset
|
243 #else |
41969
e669966d496e
Test GNU_LINUX, not LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
41275
diff
changeset
|
244 #if defined (HAVE_TERMIOS_H) && defined (GNU_LINUX) |
18808 | 245 #include <termios.h> |
16117
16c866efd8b5
[HAVE_TERMIOS_H]: Include termios.h.
Richard M. Stallman <rms@gnu.org>
parents:
16051
diff
changeset
|
246 #endif |
19023
f7a3c16c49cb
[HAVE_LIBNCURSES]: Declare ospeed as short, unless NCURSES_OSPEED_T.
Richard M. Stallman <rms@gnu.org>
parents:
18808
diff
changeset
|
247 #endif |
29252
c8f4d06938b9
(ospeed) [HAVE_SPEED_T]: Declare as `extern speed_t'.
Gerd Moellmann <gerd@gnu.org>
parents:
29150
diff
changeset
|
248 #endif |
491 | 249 |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
250 int emacs_ospeed; |
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
251 |
21769
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
252 void croak P_ ((char *)); |
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
253 |
22825
a5d08eacb02b
[AIXHFT] (hft_init, hft_reset): Add declarations.
Richard M. Stallman <rms@gnu.org>
parents:
22336
diff
changeset
|
254 #ifdef AIXHFT |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
255 void hft_init P_ ((struct tty_display_info *)); |
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
256 void hft_reset P_ ((struct tty_display_info *)); |
22825
a5d08eacb02b
[AIXHFT] (hft_init, hft_reset): Add declarations.
Richard M. Stallman <rms@gnu.org>
parents:
22336
diff
changeset
|
257 #endif |
21769
07999a47f2ee
(croak): Add forward declaration.
Richard M. Stallman <rms@gnu.org>
parents:
21532
diff
changeset
|
258 |
29812
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
259 /* Temporary used by `sigblock' when defined in terms of signprocmask. */ |
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
260 |
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
261 SIGMASKTYPE sigprocmask_set; |
e4f28eb9a373
(sigprocmask_set): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
29387
diff
changeset
|
262 |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
263 |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
264 /* Discard pending input on all input descriptors. */ |
579 | 265 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
266 void |
491 | 267 discard_tty_input () |
268 { | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
269 #ifndef WINDOWSNT |
579 | 270 struct emacs_tty buf; |
491 | 271 |
272 if (noninteractive) | |
273 return; | |
274 | |
275 #ifdef VMS | |
276 end_kbd_input (); | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
277 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, |
579 | 278 &buf.main, 0, 0, terminator_mask, 0, 0); |
491 | 279 queue_kbd_input (); |
280 #else /* not VMS */ | |
281 #ifdef APOLLO | |
282 { | |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
283 struct tty_display_info *tty; |
53232
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
284 for (tty = tty_list; tty; tty = tty->next) |
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
285 { |
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
286 int zero = 0; |
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
287 ioctl (fileno (TTY_INPUT (tty)), TIOCFLUSH, &zero); |
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
288 } |
491 | 289 } |
290 #else /* not Apollo */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
291 #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
|
292 while (dos_keyread () != -1) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
293 ; |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
294 #else /* not MSDOS */ |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
295 { |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
296 struct tty_display_info *tty; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
297 for (tty = tty_list; tty; tty = tty->next) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
298 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
299 EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
300 EMACS_SET_TTY (fileno (TTY_INPUT (tty)), &buf, 0); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
301 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
302 } |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
303 #endif /* not MSDOS */ |
491 | 304 #endif /* not Apollo */ |
305 #endif /* not VMS */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
306 #endif /* not WINDOWSNT */ |
491 | 307 } |
308 | |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
309 |
491 | 310 #ifdef SIGTSTP |
311 | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
312 /* Arrange for character C to be read as the next input from |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
313 the terminal. |
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
314 XXX What if we have multiple ttys? |
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
315 */ |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
316 |
21514 | 317 void |
48507
00bcc92f4acf
(stuff_char) [PROTOTYPES]: Provide ISO C arglist.
Dave Love <fx@gnu.org>
parents:
46952
diff
changeset
|
318 stuff_char (char c) |
491 | 319 { |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
320 if (! FRAME_TERMCAP_P (SELECTED_FRAME ())) |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
321 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
322 |
491 | 323 /* Should perhaps error if in batch mode */ |
324 #ifdef TIOCSTI | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
325 ioctl (fileno (TTY_INPUT (CURTTY())), TIOCSTI, &c); |
491 | 326 #else /* no TIOCSTI */ |
5167
6ac5c999a7cc
(init_baud_rate): Avoid referring to sg uninitialized.
Richard M. Stallman <rms@gnu.org>
parents:
5158
diff
changeset
|
327 error ("Cannot stuff terminal input characters in this version of Unix"); |
491 | 328 #endif /* no TIOCSTI */ |
329 } | |
330 | |
331 #endif /* SIGTSTP */ | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
332 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
333 void |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
334 init_baud_rate (int fd) |
491 | 335 { |
336 if (noninteractive) | |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
337 emacs_ospeed = 0; |
491 | 338 else |
339 { | |
18095
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
340 #ifdef INIT_BAUD_RATE |
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
341 INIT_BAUD_RATE (); |
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
342 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
343 #ifdef DOS_NT |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
344 emacs_ospeed = 15; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
345 #else /* not DOS_NT */ |
491 | 346 #ifdef VMS |
579 | 347 struct sensemode sg; |
348 | |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
349 SYS$QIOW (0, fd, IO$_SENSEMODE, &sg, 0, 0, |
491 | 350 &sg.class, 12, 0, 0, 0, 0 ); |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
351 emacs_ospeed = sg.xmit_baud; |
579 | 352 #else /* not VMS */ |
353 #ifdef HAVE_TERMIOS | |
354 struct termios sg; | |
355 | |
5167
6ac5c999a7cc
(init_baud_rate): Avoid referring to sg uninitialized.
Richard M. Stallman <rms@gnu.org>
parents:
5158
diff
changeset
|
356 sg.c_cflag = B9600; |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
357 tcgetattr (fd, &sg); |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
358 emacs_ospeed = cfgetospeed (&sg); |
8696
10ec51f5e4b0
(init_baud_rate): Test that getobaud is actually defined.
Richard M. Stallman <rms@gnu.org>
parents:
8690
diff
changeset
|
359 #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
|
360 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
361 if (emacs_ospeed == 0) |
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
362 emacs_ospeed = getobaud (sg.c_cflag); |
8690
83a8062ca215
(init_baud_rate) [USE_GETOBAUD]: Use getobaud.
Richard M. Stallman <rms@gnu.org>
parents:
8368
diff
changeset
|
363 #endif |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
364 #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
|
365 #ifdef HAVE_TERMIO |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
366 struct termio sg; |
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
367 |
5167
6ac5c999a7cc
(init_baud_rate): Avoid referring to sg uninitialized.
Richard M. Stallman <rms@gnu.org>
parents:
5158
diff
changeset
|
368 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
|
369 #ifdef HAVE_TCATTR |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
370 tcgetattr (fd, &sg); |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
371 #else |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
372 ioctl (fd, TCGETA, &sg); |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
373 #endif |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
374 emacs_ospeed = sg.c_cflag & CBAUD; |
1048
9899cb2199af
* sysdep.c (init_baud_rate): Re-arranged order of conditionals -
Jim Blandy <jimb@redhat.com>
parents:
1014
diff
changeset
|
375 #else /* neither VMS nor TERMIOS nor TERMIO */ |
579 | 376 struct sgttyb sg; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
377 |
579 | 378 sg.sg_ospeed = B9600; |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
379 if (ioctl (fd, TIOCGETP, &sg) < 0) |
3559
a9b886b3f976
(init_baud_rate) [HAVE_TERMIOS]: Use cfgetospeed.
Richard M. Stallman <rms@gnu.org>
parents:
3472
diff
changeset
|
380 abort (); |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
381 emacs_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
|
382 #endif /* not HAVE_TERMIO */ |
579 | 383 #endif /* not HAVE_TERMIOS */ |
491 | 384 #endif /* not VMS */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
385 #endif /* not DOS_NT */ |
18095
3cfea0947d1c
(init_baud_rate): Use INIT_BAUD_RATE if it's defined.
Richard M. Stallman <rms@gnu.org>
parents:
17869
diff
changeset
|
386 #endif /* not INIT_BAUD_RATE */ |
491 | 387 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
388 |
33617
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
389 baud_rate = (emacs_ospeed < sizeof baud_convert / sizeof baud_convert[0] |
a9247e019ab7
(emacs_ospeed): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
33217
diff
changeset
|
390 ? baud_convert[emacs_ospeed] : 9600); |
491 | 391 if (baud_rate == 0) |
392 baud_rate = 1200; | |
393 } | |
394 | |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
395 |
491 | 396 /*ARGSUSED*/ |
21514 | 397 void |
491 | 398 set_exclusive_use (fd) |
399 int fd; | |
400 { | |
401 #ifdef FIOCLEX | |
402 ioctl (fd, FIOCLEX, 0); | |
403 #endif | |
404 /* Ok to do nothing if this feature does not exist */ | |
405 } | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
406 |
491 | 407 #ifndef subprocesses |
408 | |
409 wait_without_blocking () | |
410 { | |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
411 #ifdef BSD_SYSTEM |
491 | 412 wait3 (0, WNOHANG | WUNTRACED, 0); |
413 #else | |
414 croak ("wait_without_blocking"); | |
415 #endif | |
416 synch_process_alive = 0; | |
417 } | |
418 | |
419 #endif /* not subprocesses */ | |
420 | |
421 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
|
422 (at least for bsd). */ |
491 | 423 |
424 SIGTYPE | |
425 wait_for_termination_signal () | |
426 {} | |
427 | |
428 /* Wait for subprocess with process id `pid' to terminate and | |
429 make sure it will get eliminated (not remain forever as a zombie) */ | |
430 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
431 void |
491 | 432 wait_for_termination (pid) |
433 int pid; | |
434 { | |
435 while (1) | |
436 { | |
437 #ifdef subprocesses | |
438 #ifdef VMS | |
439 int status; | |
440 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
441 status = SYS$FORCEX (&pid, 0, 0); |
491 | 442 break; |
443 #else /* not VMS */ | |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
444 #if defined (BSD_SYSTEM) || (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
|
445 /* 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
|
446 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
|
447 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
|
448 /* 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
|
449 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
|
450 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
|
451 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
|
452 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
|
453 if (0 > kill (pid, 0)) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
454 { |
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
|
455 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
|
456 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
|
457 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
|
458 } |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
459 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
|
460 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
|
461 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
|
462 sigpause (SIGEMPTYMASK); |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
463 #else /* not BSD_SYSTEM, and not HPUX version >= 6 */ |
3334
7900edb84c4f
(wait_for_termination): Delete LINUX conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
3321
diff
changeset
|
464 #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
|
465 if (0 > kill (pid, 0)) |
491 | 466 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
|
467 wait (0); |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
468 #else /* neither BSD_SYSTEM nor UNIPLUS: random sysV */ |
41969
e669966d496e
Test GNU_LINUX, not LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
41275
diff
changeset
|
469 #ifdef POSIX_SIGNALS /* would this work for GNU/Linux as well? */ |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
470 sigblock (sigmask (SIGCHLD)); |
39374
54dd36cef0e2
(wait_for_termination) [POSIX_SIGNALS]: Terminate
Gerd Moellmann <gerd@gnu.org>
parents:
39363
diff
changeset
|
471 errno = 0; |
54dd36cef0e2
(wait_for_termination) [POSIX_SIGNALS]: Terminate
Gerd Moellmann <gerd@gnu.org>
parents:
39363
diff
changeset
|
472 if (kill (pid, 0) == -1 && errno == ESRCH) |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
473 { |
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
474 sigunblock (sigmask (SIGCHLD)); |
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
475 break; |
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
476 } |
39363
50bf161d854c
(wait_for_termination): Add a FIXME comment for the use of non-POSIX
Gerd Moellmann <gerd@gnu.org>
parents:
37219
diff
changeset
|
477 |
44099
0400b67840ba
(wait_for_termination): Use sigsuspend rather than sigpause.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43713
diff
changeset
|
478 sigsuspend (&empty_mask); |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
479 #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
|
480 #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
|
481 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
|
482 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
|
483 { |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
484 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
|
485 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
|
486 } |
9ac629dc3a4b
(wait_for_termination): Copy code from 18.59 (but sans BSD4_1 alternatives).
Richard M. Stallman <rms@gnu.org>
parents:
2939
diff
changeset
|
487 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
|
488 #else /* not HAVE_SYSV_SIGPAUSE */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
489 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
490 wait (0); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
491 break; |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
492 #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
|
493 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
|
494 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
|
495 /* 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
|
496 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
|
497 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
|
498 sleep (1); |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
499 #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
|
500 #endif /* not HAVE_SYSV_SIGPAUSE */ |
3301
aaf396661221
(wait_for_termination): Add POSIX_SIGNALS alternative.
Richard M. Stallman <rms@gnu.org>
parents:
3292
diff
changeset
|
501 #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
|
502 #endif /* not UNIPLUS */ |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
503 #endif /* not BSD_SYSTEM, and not HPUX version >= 6 */ |
491 | 504 #endif /* not VMS */ |
505 #else /* not subprocesses */ | |
14971
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
506 #if __DJGPP__ > 1 |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
507 break; |
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
508 #else /* not __DJGPP__ > 1 */ |
491 | 509 #ifndef BSD4_1 |
510 if (kill (pid, 0) < 0) | |
511 break; | |
512 wait (0); | |
513 #else /* BSD4_1 */ | |
514 int status; | |
515 status = wait (0); | |
516 if (status == pid || status == -1) | |
517 break; | |
518 #endif /* BSD4_1 */ | |
14971
497b73cc5818
[DJGPP v2] (etext, start): Declared.
Richard M. Stallman <rms@gnu.org>
parents:
14790
diff
changeset
|
519 #endif /* not __DJGPP__ > 1*/ |
491 | 520 #endif /* not subprocesses */ |
521 } | |
522 } | |
523 | |
524 #ifdef subprocesses | |
525 | |
526 /* | |
527 * flush any pending output | |
528 * (may flush input as well; it does not matter the way we use it) | |
529 */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
530 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
531 void |
491 | 532 flush_pending_output (channel) |
533 int channel; | |
534 { | |
535 #ifdef HAVE_TERMIOS | |
536 /* If we try this, we get hit with SIGTTIN, because | |
537 the child's tty belongs to the child's pgrp. */ | |
538 #else | |
539 #ifdef TCFLSH | |
540 ioctl (channel, TCFLSH, 1); | |
541 #else | |
542 #ifdef TIOCFLUSH | |
543 int zero = 0; | |
544 /* 3rd arg should be ignored | |
545 but some 4.2 kernels actually want the address of an int | |
546 and nonzero means something different. */ | |
547 ioctl (channel, TIOCFLUSH, &zero); | |
548 #endif | |
549 #endif | |
550 #endif | |
551 } | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
552 |
491 | 553 #ifndef VMS |
554 /* Set up the terminal at the other end of a pseudo-terminal that | |
555 we will be controlling an inferior through. | |
556 It should not echo or do line-editing, since that is done | |
557 in Emacs. No padding needed for insertion into an Emacs buffer. */ | |
558 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
559 void |
491 | 560 child_setup_tty (out) |
561 int out; | |
562 { | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
563 #ifndef DOS_NT |
579 | 564 struct emacs_tty s; |
565 | |
566 EMACS_GET_TTY (out, &s); | |
567 | |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
568 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
579 | 569 s.main.c_oflag |= OPOST; /* Enable output postprocessing */ |
570 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
|
571 #ifdef NLDLY |
579 | 572 s.main.c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY); |
573 /* 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
|
574 #endif |
579 | 575 s.main.c_lflag &= ~ECHO; /* Disable echo */ |
576 s.main.c_lflag |= ISIG; /* Enable signals */ | |
41275 | 577 #if 0 /* This causes bugs in (for instance) telnet to certain sites. */ |
39685
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
578 s.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
579 #ifdef INLCR /* Just being cautious, since I can't check how |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
580 widespread INLCR is--rms. */ |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
581 s.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */ |
39ebccb06546
(child_setup_tty) [HAVE_TERMIO || HAVE_TERMIOS]:
Gerd Moellmann <gerd@gnu.org>
parents:
39682
diff
changeset
|
582 #endif |
40932
103ddc9d157a
(child_setup_tty): Don't clear ICRNL or INLCR.
Richard M. Stallman <rms@gnu.org>
parents:
40122
diff
changeset
|
583 #endif |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
584 #ifdef IUCLC |
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
585 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
|
586 #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
|
587 #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
|
588 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
|
589 #endif |
5972
ccb0f99750e3
(child_setup_tty): Typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
5967
diff
changeset
|
590 #ifdef OLCUC |
5967
ac268a6d91d6
(child_setup_tty): Use IUCLC, OLCUC, NLDLY only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5964
diff
changeset
|
591 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
|
592 #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
|
593 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
|
594 s.main.c_cflag = (s.main.c_cflag & ~CSIZE) | CS8; /* Don't strip 8th bit */ |
579 | 595 #if 0 |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
596 /* Said to be unnecessary: */ |
579 | 597 s.main.c_cc[VMIN] = 1; /* minimum number of characters to accept */ |
598 s.main.c_cc[VTIME] = 0; /* wait forever for at least 1 character */ | |
599 #endif | |
600 | |
601 s.main.c_lflag |= ICANON; /* Enable erase/kill and eof processing */ | |
602 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
|
603 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
|
604 s.main.c_cc[VKILL] = CDISABLE; /* disable kill processing */ |
579 | 605 |
491 | 606 #ifdef HPUX |
579 | 607 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ |
491 | 608 #endif /* HPUX */ |
579 | 609 |
491 | 610 #ifdef AIX |
611 /* AIX enhanced edit loses NULs, so disable it */ | |
612 #ifndef IBMR2AIX | |
579 | 613 s.main.c_line = 0; |
614 s.main.c_iflag &= ~ASCEDIT; | |
491 | 615 #endif |
616 /* Also, PTY overloads NUL and BREAK. | |
617 don't ignore break, but don't signal either, so it looks like NUL. */ | |
579 | 618 s.main.c_iflag &= ~IGNBRK; |
619 s.main.c_iflag &= ~BRKINT; | |
620 /* QUIT and INTR work better as signals, so disable character forms */ | |
621 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
|
622 #ifdef SIGNALS_VIA_CHARACTERS |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
623 /* 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
|
624 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
|
625 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
|
626 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
|
627 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
|
628 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
|
629 #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
|
630 /* 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
|
631 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
|
632 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
|
633 s.main.c_lflag &= ~ISIG; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
634 #endif /* no TIOCGPGRP or no TIOCGLTC or no TIOCGETC */ |
579 | 635 s.main.c_cc[VEOL] = 0377; |
636 s.main.c_cflag = (s.main.c_cflag & ~CBAUD) | B9600; /* baud rate sanity */ | |
491 | 637 #endif /* AIX */ |
638 | |
639 #else /* not HAVE_TERMIO */ | |
579 | 640 |
641 s.main.sg_flags &= ~(ECHO | CRMOD | ANYP | ALLDELAY | RAW | LCASE | |
642 | CBREAK | TANDEM); | |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
643 s.main.sg_flags |= LPASS8; |
579 | 644 s.main.sg_erase = 0377; |
645 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
|
646 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */ |
579 | 647 |
491 | 648 #endif /* not HAVE_TERMIO */ |
649 | |
579 | 650 EMACS_SET_TTY (out, &s, 0); |
491 | 651 |
652 #ifdef BSD4_1 | |
653 if (interrupt_input) | |
53341 | 654 reset_sigio (0); |
491 | 655 #endif /* BSD4_1 */ |
656 #ifdef RTU | |
657 { | |
658 int zero = 0; | |
659 ioctl (out, FIOASYNC, &zero); | |
660 } | |
661 #endif /* RTU */ | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
662 #endif /* not DOS_NT */ |
491 | 663 } |
664 #endif /* not VMS */ | |
665 | |
666 #endif /* subprocesses */ | |
4681
6945d02dd725
(stuff_char): Use input_fd.
Richard M. Stallman <rms@gnu.org>
parents:
4643
diff
changeset
|
667 |
491 | 668 /* Record a signal code and the handler for it. */ |
669 struct save_signal | |
670 { | |
671 int code; | |
20348 | 672 SIGTYPE (*handler) P_ ((int)); |
491 | 673 }; |
674 | |
20348 | 675 static void save_signal_handlers P_ ((struct save_signal *)); |
676 static void restore_signal_handlers P_ ((struct save_signal *)); | |
677 | |
491 | 678 /* Suspend the Emacs process; give terminal to its superior. */ |
679 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
680 void |
491 | 681 sys_suspend () |
682 { | |
683 #ifdef VMS | |
1171
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
684 /* "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
|
685 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
|
686 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
|
687 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
|
688 char *fpid_string; |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
689 |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
690 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
|
691 if (fpid_string != NULL) |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
692 { |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
693 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
|
694 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
|
695 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
|
696 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
697 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
698 } |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
699 else |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
700 parent_id = getppid (); |
5c942f6b2d63
(sys_suspend): Read EMACS_PARENT_PID envvar for parent.
Richard M. Stallman <rms@gnu.org>
parents:
1102
diff
changeset
|
701 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
702 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
|
703 |
491 | 704 if (parent_id && parent_id != 0xffffffff) |
705 { | |
706 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); | |
707 int status = LIB$ATTACH (&parent_id) & 1; | |
708 signal (SIGINT, oldsig); | |
709 return status; | |
710 } | |
711 else | |
712 { | |
713 struct { | |
714 int l; | |
715 char *a; | |
716 } d_prompt; | |
717 d_prompt.l = sizeof ("Emacs: "); /* Our special prompt */ | |
718 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
|
719 LIB$SPAWN (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &d_prompt, 0); |
491 | 720 return 1; |
721 } | |
722 return -1; | |
723 #else | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
724 #if defined (SIGTSTP) && !defined (MSDOS) |
491 | 725 |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
726 { |
4958
8d58e388e71b
(sys_suspend): Use EMACS_GETPGRP macro.
Richard M. Stallman <rms@gnu.org>
parents:
4952
diff
changeset
|
727 int pgrp = EMACS_GETPGRP (0); |
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
728 EMACS_KILLPG (pgrp, SIGTSTP); |
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3797
diff
changeset
|
729 } |
491 | 730 |
731 #else /* No SIGTSTP */ | |
732 #ifdef USG_JOBCTRL /* If you don't know what this is don't mess with it */ | |
733 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */ | |
734 kill (getpid (), SIGQUIT); | |
735 | |
736 #else /* No SIGTSTP or USG_JOBCTRL */ | |
737 | |
738 /* On a system where suspending is not implemented, | |
739 instead fork a subshell and let it talk directly to the terminal | |
740 while we wait. */ | |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
741 sys_subshell (); |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
742 |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
743 #endif /* no USG_JOBCTRL */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
744 #endif /* no SIGTSTP */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
745 #endif /* not VMS */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
746 } |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
747 |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
748 /* Fork a subshell. */ |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
749 |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44099
diff
changeset
|
750 #ifndef MAC_OS8 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
751 void |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
752 sys_subshell () |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
753 { |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
754 #ifndef VMS |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
755 #ifdef DOS_NT /* Demacs 1.1.2 91/10/20 Manabu Higashida */ |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
756 int st; |
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
757 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
|
758 #endif |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
759 int pid; |
491 | 760 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
|
761 Lisp_Object dir; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
762 unsigned char *str = 0; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
763 int len; |
491 | 764 |
765 saved_handlers[0].code = SIGINT; | |
766 saved_handlers[1].code = SIGQUIT; | |
767 saved_handlers[2].code = SIGTERM; | |
768 #ifdef SIGIO | |
769 saved_handlers[3].code = SIGIO; | |
770 saved_handlers[4].code = 0; | |
771 #else | |
772 saved_handlers[3].code = 0; | |
773 #endif | |
774 | |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
775 /* 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
|
776 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
|
777 |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
778 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
|
779 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
|
780 goto xyzzy; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
781 dir = Fsymbol_value (dir); |
9110
c0eefdfd11f4
(sys_subshell): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9082
diff
changeset
|
782 if (!STRINGP (dir)) |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
783 goto xyzzy; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
784 |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
785 dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46298
diff
changeset
|
786 str = (unsigned char *) alloca (SCHARS (dir) + 2); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46298
diff
changeset
|
787 len = SCHARS (dir); |
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46298
diff
changeset
|
788 bcopy (SDATA (dir), str, len); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
789 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
|
790 str[len] = 0; |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
791 xyzzy: |
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
792 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
793 #ifdef DOS_NT |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
794 pid = 0; |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
795 #if __DJGPP__ > 1 |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
796 save_signal_handlers (saved_handlers); |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
797 synch_process_alive = 1; |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
798 #endif /* __DJGPP__ > 1 */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
799 #else |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
800 pid = vfork (); |
491 | 801 if (pid == -1) |
802 error ("Can't spawn subshell"); | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
803 #endif |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
804 |
491 | 805 if (pid == 0) |
806 { | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
807 char *sh = 0; |
491 | 808 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
809 #ifdef DOS_NT /* MW, Aug 1993 */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
810 getwd (oldwd); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
811 if (sh == 0) |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
812 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
|
813 #endif |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
814 if (sh == 0) |
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
815 sh = (char *) egetenv ("SHELL"); |
491 | 816 if (sh == 0) |
817 sh = "sh"; | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
818 |
491 | 819 /* 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
|
820 if (str) |
22336
0af99a2dc706
(sys_subshell): Cast arg to chdir.
Karl Heuer <kwzh@gnu.org>
parents:
21843
diff
changeset
|
821 chdir ((char *) str); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
822 |
491 | 823 #ifdef subprocesses |
824 close_process_descs (); /* Close Emacs's pipes/ptys */ | |
825 #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
|
826 |
7482
8193d122cf6e
(sys_subshell): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7326
diff
changeset
|
827 #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
|
828 { |
43713
f92c4d87863a
Change defvar_int def and vars to use EMACS_INT instead of just int.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43708
diff
changeset
|
829 extern EMACS_INT 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
|
830 |
7482
8193d122cf6e
(sys_subshell): PRIO_PROCESS renamed to SET_EMACS_PRIORITY.
Richard M. Stallman <rms@gnu.org>
parents:
7326
diff
changeset
|
831 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
|
832 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
|
833 } |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
834 #endif |
bc1acd76b294
* sysdep.c (sys_suspend): Don't try to use "nice (- nice (0))" to
Jim Blandy <jimb@redhat.com>
parents:
1171
diff
changeset
|
835 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
836 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ |
43706
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
837 { |
43708
8d176857311d
(sys_subshell): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
43706
diff
changeset
|
838 char *epwd = getenv ("PWD"); |
8d176857311d
(sys_subshell): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
43706
diff
changeset
|
839 char old_pwd[MAXPATHLEN+1+4]; |
43706
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
840 |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
841 /* If PWD is set, pass it with corrected value. */ |
43708
8d176857311d
(sys_subshell): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
43706
diff
changeset
|
842 if (epwd) |
43706
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
843 { |
43708
8d176857311d
(sys_subshell): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
43706
diff
changeset
|
844 strcpy (old_pwd, epwd); |
43706
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
845 if (str[len - 1] == '/') |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
846 str[len - 1] = '\0'; |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
847 setenv ("PWD", str, 1); |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
848 } |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
849 st = system (sh); |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
850 chdir (oldwd); |
43708
8d176857311d
(sys_subshell): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
43706
diff
changeset
|
851 if (epwd) |
43706
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
852 putenv (old_pwd); /* restore previous value */ |
009de2eaf047
(sys_subshell) [MSDOS]: If PWD is set in the
Eli Zaretskii <eliz@gnu.org>
parents:
43177
diff
changeset
|
853 } |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
854 #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
|
855 if (st) |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
856 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
|
857 #endif |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
858 #else /* not MSDOS */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
859 #ifdef WINDOWSNT |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
860 /* Waits for process completion */ |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
861 pid = _spawnlp (_P_WAIT, sh, sh, NULL); |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
862 chdir (oldwd); |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
863 if (pid == -1) |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
864 write (1, "Can't execute subshell", 22); |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
865 #else /* not WINDOWSNT */ |
491 | 866 execlp (sh, sh, 0); |
867 write (1, "Can't execute subshell", 22); | |
868 _exit (1); | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
869 #endif /* not WINDOWSNT */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
870 #endif /* not MSDOS */ |
491 | 871 } |
872 | |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
873 /* Do this now if we did not do it before. */ |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
874 #if !defined (MSDOS) || __DJGPP__ == 1 |
491 | 875 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
|
876 synch_process_alive = 1; |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
877 #endif |
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
878 |
19699
ce0b47a57e23
(sys_subshell) [DOS_NT]: Save and restore parent's
Geoff Voelker <voelker@cs.washington.edu>
parents:
19639
diff
changeset
|
879 #ifndef DOS_NT |
491 | 880 wait_for_termination (pid); |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
881 #endif |
491 | 882 restore_signal_handlers (saved_handlers); |
14991
0147f1c8cd2c
(sys_subshell): Add conditionals for DJGPP v2.
Richard M. Stallman <rms@gnu.org>
parents:
14971
diff
changeset
|
883 synch_process_alive = 0; |
6102
a92ee78acd12
(sys_subshell): New function, split from sys_suspend.
Karl Heuer <kwzh@gnu.org>
parents:
5972
diff
changeset
|
884 #endif /* !VMS */ |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
885 } |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44099
diff
changeset
|
886 #endif /* !MAC_OS8 */ |
491 | 887 |
20348 | 888 static void |
491 | 889 save_signal_handlers (saved_handlers) |
890 struct save_signal *saved_handlers; | |
891 { | |
892 while (saved_handlers->code) | |
893 { | |
692 | 894 saved_handlers->handler |
20348 | 895 = (SIGTYPE (*) P_ ((int))) signal (saved_handlers->code, SIG_IGN); |
491 | 896 saved_handlers++; |
897 } | |
898 } | |
899 | |
20348 | 900 static void |
491 | 901 restore_signal_handlers (saved_handlers) |
902 struct save_signal *saved_handlers; | |
903 { | |
904 while (saved_handlers->code) | |
905 { | |
906 signal (saved_handlers->code, saved_handlers->handler); | |
907 saved_handlers++; | |
908 } | |
909 } | |
910 | |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
911 #ifndef SIGIO |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
912 /* If SIGIO is broken, don't do anything. */ |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
913 void |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
914 init_sigio (int fd) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
915 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
916 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
917 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
918 void |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
919 reset_sigio (int fd) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
920 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
921 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
922 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
923 void |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
924 request_sigio (void) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
925 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
926 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
927 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
928 void |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
929 unrequest_sigio (void) |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
930 { |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
931 } |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
932 |
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
933 #else |
491 | 934 #ifdef F_SETFL |
935 | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
936 int old_fcntl_flags[MAXDESC]; |
491 | 937 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
938 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
939 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
940 int fd; |
491 | 941 { |
942 #ifdef FASYNC | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
943 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
944 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); |
491 | 945 #endif |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
946 interrupts_deferred = 0; |
491 | 947 } |
948 | |
20379
e6db4b8d2834
(reset_sigio): Return void.
Andreas Schwab <schwab@suse.de>
parents:
20367
diff
changeset
|
949 void |
53341 | 950 reset_sigio (fd) |
951 int fd; | |
491 | 952 { |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
953 #ifdef FASYNC |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
954 fcntl (fd, F_SETFL, old_fcntl_flags[fd]); |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
955 #endif |
491 | 956 } |
957 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
958 #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
959 /* XXX Uhm, FASYNC is not used anymore here. */ |
491 | 960 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
961 void |
491 | 962 request_sigio () |
963 { | |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
964 /* XXX read_socket_hook is not global anymore. Is blocking SIGIO |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
965 bad under X? */ |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
966 #if 0 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
967 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
968 return; |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
969 #endif |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
970 |
491 | 971 #ifdef SIGWINCH |
638 | 972 sigunblock (sigmask (SIGWINCH)); |
491 | 973 #endif |
53341 | 974 sigunblock (sigmask (SIGIO)); |
491 | 975 |
976 interrupts_deferred = 0; | |
977 } | |
978 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
979 void |
53341 | 980 unrequest_sigio (void) |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
981 { |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
982 /* XXX read_socket_hook is not global anymore. Is blocking SIGIO |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
983 bad under X? */ |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
984 #if 0 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
985 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
986 return; |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
987 #endif |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
988 |
491 | 989 #ifdef SIGWINCH |
638 | 990 sigblock (sigmask (SIGWINCH)); |
491 | 991 #endif |
53341 | 992 sigblock (sigmask (SIGIO)); |
491 | 993 interrupts_deferred = 1; |
994 } | |
995 | |
996 #else /* no FASYNC */ | |
997 #ifdef STRIDE /* Stride doesn't have FASYNC - use FIOASYNC */ | |
998 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
999 void |
491 | 1000 request_sigio () |
1001 { | |
1002 int on = 1; | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1003 |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1004 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1005 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1006 |
53341 | 1007 /* XXX CURTTY() is bogus here. */ |
1008 ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &on); | |
491 | 1009 interrupts_deferred = 0; |
1010 } | |
1011 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1012 void |
491 | 1013 unrequest_sigio () |
1014 { | |
1015 int off = 0; | |
1016 | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1017 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1018 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1019 |
53341 | 1020 /* XXX CURTTY() is bogus here. */ |
1021 ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &off); | |
491 | 1022 interrupts_deferred = 1; |
1023 } | |
1024 | |
1025 #else /* not FASYNC, not STRIDE */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1026 |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1027 #ifdef _CX_UX |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1028 |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1029 #include <termios.h> |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1030 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1031 void |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1032 request_sigio () |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1033 { |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1034 int on = 1; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1035 sigset_t st; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1036 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1037 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1038 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1039 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1040 sigemptyset (&st); |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1041 sigaddset (&st, SIGIO); |
53341 | 1042 ioctl (0, FIOASYNC, &on); /* XXX This fails for multiple ttys. */ |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1043 interrupts_deferred = 0; |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1044 sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1045 } |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1046 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1047 void |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1048 unrequest_sigio () |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1049 { |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1050 int off = 0; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1051 |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1052 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1053 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1054 |
53341 | 1055 ioctl (0, FIOASYNC, &off); /* XXX This fails for multiple ttys. */ |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1056 interrupts_deferred = 1; |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1057 } |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1058 |
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1059 #else /* ! _CX_UX */ |
46952
2ff6f626f0ce
[MSDOS]: Don't define request_sigio and
Eli Zaretskii <eliz@gnu.org>
parents:
46922
diff
changeset
|
1060 #ifndef MSDOS |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1061 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1062 void |
491 | 1063 request_sigio () |
1064 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1065 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1066 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1067 |
491 | 1068 croak ("request_sigio"); |
1069 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1070 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1071 void |
491 | 1072 unrequest_sigio () |
1073 { | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1074 if (read_socket_hook) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1075 return; |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
1076 |
491 | 1077 croak ("unrequest_sigio"); |
1078 } | |
46952
2ff6f626f0ce
[MSDOS]: Don't define request_sigio and
Eli Zaretskii <eliz@gnu.org>
parents:
46922
diff
changeset
|
1079 |
2ff6f626f0ce
[MSDOS]: Don't define request_sigio and
Eli Zaretskii <eliz@gnu.org>
parents:
46922
diff
changeset
|
1080 #endif /* MSDOS */ |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
1081 #endif /* _CX_UX */ |
491 | 1082 #endif /* STRIDE */ |
1083 #endif /* FASYNC */ | |
1084 #endif /* F_SETFL */ | |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
1085 #endif /* SIGIO */ |
491 | 1086 |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1087 /* 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
|
1088 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1089 #ifdef BSD_PGRPS |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1090 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1091 /* 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
|
1092 started. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1093 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1094 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
|
1095 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
|
1096 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
|
1097 Everything is fine. |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1098 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 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
|
1104 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
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 int inherited_pgroup; |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1110 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1111 /* 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
|
1112 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
|
1113 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
|
1114 to be in our own process group to receive SIGIO properly. */ |
21514 | 1115 void |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1116 narrow_foreground_group (int fd) |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1117 { |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1118 int me = getpid (); |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1119 |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1120 if (! inherited_pgroup) |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1121 inherited_pgroup = getpgid (0); |
53232
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
1122 /* XXX This only works on the controlling tty. */ |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1123 if (inherited_pgroup != me) |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1124 EMACS_SET_TTY_PGRP (fd, &me); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1125 setpgid (0, me); |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1126 } |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1127 |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1128 /* Set the tty to our original foreground group. */ |
21514 | 1129 void |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1130 widen_foreground_group (int fd) |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1131 { |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1132 if (inherited_pgroup != getpid ()) |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1133 EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1134 setpgid (0, inherited_pgroup); |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1135 } |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1136 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1137 #endif /* BSD_PGRPS */ |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1138 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1139 /* 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
|
1140 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1141 /* 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
|
1142 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
|
1143 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
|
1144 int |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1145 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
|
1146 int fd; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1147 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
|
1148 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1149 /* 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
|
1150 #ifdef HAVE_TCATTR |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1151 /* We have those nifty POSIX tcmumbleattr functions. */ |
21843
600f19764b68
(emacs_get_tty): Zero out termios structure before
Andreas Schwab <schwab@suse.de>
parents:
21769
diff
changeset
|
1152 bzero (&settings->main, sizeof (settings->main)); |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1153 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
|
1154 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1155 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1156 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1157 #ifdef HAVE_TERMIO |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1158 /* 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
|
1159 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
|
1160 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1161 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1162 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1163 #ifdef VMS |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1164 /* Vehemently Monstrous System? :-) */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1165 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
|
1166 &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
|
1167 & 1)) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1168 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1169 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1170 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1171 #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
|
1172 /* 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
|
1173 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
|
1174 return -1; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1175 #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
|
1176 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1177 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1178 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1179 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1180 /* 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
|
1181 #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
|
1182 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
|
1183 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1184 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1185 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1186 /* 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
|
1187 #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
|
1188 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
|
1189 || 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
|
1190 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1191 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1192 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1193 /* 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
|
1194 return 0; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1195 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1196 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1197 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1198 /* 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
|
1199 *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
|
1200 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
|
1201 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1202 int |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1203 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
|
1204 int fd; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1205 struct emacs_tty *settings; |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1206 int flushp; |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1207 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1208 /* 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
|
1209 #ifdef HAVE_TCATTR |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1210 int i; |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1211 /* 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
|
1212 William J. Smith <wjs@wiis.wang.com> writes: |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1213 "POSIX 1003.1 defines tcsetattr to return success if it was |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1214 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
|
1215 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
|
1216 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
|
1217 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
|
1218 /* 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
|
1219 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
|
1220 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
|
1221 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1222 if (errno == EINTR) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1223 continue; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1224 else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1225 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1226 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1227 else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1228 { |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1229 struct termios new; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1230 |
21843
600f19764b68
(emacs_get_tty): Zero out termios structure before
Andreas Schwab <schwab@suse.de>
parents:
21769
diff
changeset
|
1231 bzero (&new, sizeof (new)); |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1232 /* 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
|
1233 tcgetattr (fd, &new); |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1234 /* 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
|
1235 * 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
|
1236 * not be filled in. |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1237 */ |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1238 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
|
1239 && 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
|
1240 && 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
|
1241 && new.c_lflag == settings->main.c_lflag |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1242 && memcmp (new.c_cc, settings->main.c_cc, NCCS) == 0) |
3321
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1243 break; |
d2adfd22a854
(child_setup_tty) [AIX SIGNALS_VIA_CHARACTERS]: Install
Richard M. Stallman <rms@gnu.org>
parents:
3301
diff
changeset
|
1244 else |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1245 continue; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1246 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1247 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1248 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1249 #ifdef HAVE_TERMIO |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1250 /* The SYSV-style interface? */ |
12231
c00af359fde5
(emacs_set_tty): Swap TCSETAF and TCSETAW.
Richard M. Stallman <rms@gnu.org>
parents:
12070
diff
changeset
|
1251 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
|
1252 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1253 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1254 #else |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1255 #ifdef VMS |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1256 /* Vehemently Monstrous System? :-) */ |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1257 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
|
1258 &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
|
1259 & 1)) |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1260 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1261 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1262 #else |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1263 #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
|
1264 /* 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
|
1265 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
|
1266 return -1; |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1267 #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
|
1268 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1269 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1270 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1271 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1272 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1273 /* 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
|
1274 #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
|
1275 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
|
1276 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1277 #endif |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1278 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1279 /* 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
|
1280 #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
|
1281 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
|
1282 || 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
|
1283 return -1; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1284 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1285 |
2656
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1286 /* 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
|
1287 return 0; |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1288 } |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1289 |
93eda11d38de
* systty.h (EMACS_GET_TTY, EMACS_SET_TTY): Move these into
Jim Blandy <jimb@redhat.com>
parents:
2589
diff
changeset
|
1290 |
491 | 1291 |
579 | 1292 #ifdef BSD4_1 |
1293 /* BSD 4.1 needs to keep track of the lmode bits in order to start | |
1294 sigio. */ | |
1295 int lmode; | |
1296 #endif | |
1297 | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1298 #ifndef F_SETOWN_BUG |
491 | 1299 #ifdef F_SETOWN |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1300 int old_fcntl_owner[MAXDESC]; |
491 | 1301 #endif /* F_SETOWN */ |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1302 #endif /* F_SETOWN_BUG */ |
491 | 1303 |
1304 /* This may also be defined in stdio, | |
1305 but if so, this does no harm, | |
1306 and using the same name avoids wasting the other one's space. */ | |
1307 | |
23631
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1308 #ifdef nec_ews_svr4 |
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1309 extern char *_sobuf ; |
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1310 #else |
491 | 1311 #if defined (USG) || defined (DGUX) |
1312 unsigned char _sobuf[BUFSIZ+8]; | |
1313 #else | |
1314 char _sobuf[BUFSIZ]; | |
1315 #endif | |
23631
c4c37f5b8df6
[nec_ews_svr4]: Extern *_sobuf.
Kenichi Handa <handa@m17n.org>
parents:
22825
diff
changeset
|
1316 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1317 |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1318 #ifdef HAVE_LTCHARS |
491 | 1319 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; |
1320 #endif | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1321 #ifdef HAVE_TCHARS |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1322 static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1}; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1323 #endif |
491 | 1324 |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1325 /* Initialize the terminal mode on all tty devices that are currently |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1326 open. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1327 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1328 void |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1329 init_all_sys_modes (void) |
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1330 { |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
1331 struct tty_display_info *tty; |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1332 for (tty = tty_list; tty; tty = tty->next) |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1333 init_sys_modes (tty); |
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1334 } |
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1335 |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1336 /* Initialize the terminal mode on the given tty device. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1337 |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1338 void |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1339 init_sys_modes (tty_out) |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
1340 struct tty_display_info *tty_out; |
491 | 1341 { |
579 | 1342 struct emacs_tty tty; |
1343 | |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44099
diff
changeset
|
1344 #ifdef MAC_OS8 |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
1345 /* cus-start.el complains if delete-exited-processes is not defined */ |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1346 #ifndef subprocesses |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1347 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, |
40122
4a487543a226
(delete-exited-processes): Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39685
diff
changeset
|
1348 doc: /* *Non-nil means delete processes immediately when they exit. |
4a487543a226
(delete-exited-processes): Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39685
diff
changeset
|
1349 nil means don't delete them until `list-processes' is run. */); |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1350 delete_exited_processes = 0; |
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1351 #endif |
44890
01b93e5e53a7
Patch for building Emacs on Mac OS X. April 26, 2002. See ChangeLog,
Andrew Choi <akochoi@shaw.ca>
parents:
44099
diff
changeset
|
1352 #endif /* MAC_OS8 */ |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
1353 |
491 | 1354 #ifdef VMS |
1355 #if 0 | |
1356 static int oob_chars[2] = {0, 1 << 7}; /* catch C-g's */ | |
1357 extern int (*interrupt_signal) (); | |
1358 #endif | |
1359 #endif | |
1360 | |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1361 Vtty_erase_char = Qnil; |
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1362 |
491 | 1363 if (noninteractive) |
1364 return; | |
1365 | |
1366 #ifdef VMS | |
1367 if (!input_ef) | |
1368 input_ef = get_kbd_event_flag (); | |
1369 /* LIB$GET_EF (&input_ef); */ | |
1370 SYS$CLREF (input_ef); | |
1371 waiting_for_ast = 0; | |
1372 if (!timer_ef) | |
1373 timer_ef = get_timer_event_flag (); | |
1374 /* LIB$GET_EF (&timer_ef); */ | |
1375 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
|
1376 #if 0 |
491 | 1377 if (!process_ef) |
1378 { | |
1379 LIB$GET_EF (&process_ef); | |
1380 SYS$CLREF (process_ef); | |
1381 } | |
1382 if (input_ef / 32 != process_ef / 32) | |
1383 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
|
1384 #endif |
491 | 1385 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
|
1386 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
|
1387 #if 0 |
491 | 1388 input_eflist = ((unsigned) 1 << (input_ef % 32)) | |
1389 ((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
|
1390 #endif |
491 | 1391 timer_eflist = ((unsigned) 1 << (input_ef % 32)) | |
1392 ((unsigned) 1 << (timer_ef % 32)); | |
1393 #ifndef VMS4_4 | |
1394 sys_access_reinit (); | |
1395 #endif | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1396 #endif /* VMS */ |
579 | 1397 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1398 #ifdef BSD_PGRPS |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
1399 #if 0 |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
1400 /* read_socket_hook is not global anymore. I think doing this |
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
1401 unconditionally will not cause any problems. */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1402 if (! read_socket_hook && EQ (Vinitial_window_system, Qnil)) |
83004
7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
82995
diff
changeset
|
1403 #endif |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1404 narrow_foreground_group (fileno (TTY_INPUT (tty_out))); |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1405 #endif |
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1406 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1407 if (! tty_out->old_tty) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1408 tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty)); |
53233
fe9b37bee5f7
Fully eliminated global tty state variables.
Karoly Lorentey <lorentey@elte.hu>
parents:
53232
diff
changeset
|
1409 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1410 EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), tty_out->old_tty); |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1411 |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1412 tty = *tty_out->old_tty; |
491 | 1413 |
1927
c6dc1a37aeb4
* sysdep.c (child_setup_tty): Recognize HAVE_TERMIOS as well as
Jim Blandy <jimb@redhat.com>
parents:
1596
diff
changeset
|
1414 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1415 XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]); |
17869
a2fefbc6e46b
(init_sys_modes): Initialize Vtty_erase_char if
Richard M. Stallman <rms@gnu.org>
parents:
17108
diff
changeset
|
1416 |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1417 #ifdef DGUX |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1418 /* This allows meta to be sent on 8th bit. */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1419 tty.main.c_iflag &= ~INPCK; /* don't check input for parity */ |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1420 #endif |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1421 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1422 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
|
1423 #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
|
1424 since I can't check how widespread INLCR is--rms. */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1425 tty.main.c_iflag &= ~INLCR; /* Disable map of NL to CR on input */ |
14790
70553c545976
(init_sys_modes): Clear INLCR like ICRNL.
Richard M. Stallman <rms@gnu.org>
parents:
14390
diff
changeset
|
1426 #endif |
491 | 1427 #ifdef ISTRIP |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1428 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ |
491 | 1429 #endif |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1430 tty.main.c_lflag &= ~ECHO; /* Disable echo */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1431 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
|
1432 #ifdef IEXTEN |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1433 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
|
1434 #endif |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1435 tty.main.c_lflag |= ISIG; /* Enable signals */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1436 if (tty_out->flow_control) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1437 { |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1438 tty.main.c_iflag |= IXON; /* Enable start/stop output control */ |
491 | 1439 #ifdef IXANY |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1440 tty.main.c_iflag &= ~IXANY; |
491 | 1441 #endif /* IXANY */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1442 } |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1443 else |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1444 tty.main.c_iflag &= ~IXON; /* Disable start/stop output control */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1445 tty.main.c_oflag &= ~ONLCR; /* Disable map of NL to CR-NL |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1446 on output */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1447 tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ |
491 | 1448 #ifdef CS8 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1449 if (tty_out->meta_key) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1450 { |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1451 tty.main.c_cflag |= CS8; /* allow 8th bit on input */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1452 tty.main.c_cflag &= ~PARENB;/* Don't check parity */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1453 } |
491 | 1454 #endif |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1455 if (tty_out->input == stdin) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1456 { |
579 | 1457 tty.main.c_cc[VINTR] = quit_char; /* C-g (usually) gives SIGINT */ |
491 | 1458 /* Set up C-g for both SIGQUIT and SIGINT. |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1459 We don't know which we will get, but we handle both alike |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1460 so which one it really gives us does not matter. */ |
579 | 1461 tty.main.c_cc[VQUIT] = quit_char; |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1462 } |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1463 else |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1464 { |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1465 /* We normally don't get interrupt or quit signals from tty |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1466 devices other than our controlling terminal; therefore, |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1467 we must handle C-g as normal input. Unfortunately, this |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1468 means that the interrupt and quit feature must be |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1469 disabled on secondary ttys, or we would not even see the |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1470 keypress. |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1471 |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1472 Note that even though emacsclient could have special code |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1473 to pass SIGINT to Emacs, we should _not_ enable |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1474 interrupt/quit keys for emacsclient frames. This means |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1475 that we can't break out of loops in C code from a |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1476 secondary tty frame, but we can always decide what |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1477 display the C-g came from, which is more important from a |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1478 usability point of view. (Consider the case when two |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1479 people work together using the same Emacs instance.) */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1480 tty.main.c_cc[VINTR] = CDISABLE; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1481 tty.main.c_cc[VQUIT] = CDISABLE; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1482 } |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1483 tty.main.c_cc[VMIN] = 1; /* Input should wait for at least 1 char */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1484 tty.main.c_cc[VTIME] = 0; /* no matter how long that takes. */ |
491 | 1485 #ifdef VSWTCH |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1486 tty.main.c_cc[VSWTCH] = CDISABLE; /* Turn off shell layering use |
579 | 1487 of C-z */ |
491 | 1488 #endif /* VSWTCH */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1489 |
491 | 1490 #if defined (mips) || defined (HAVE_TCATTR) |
1491 #ifdef VSUSP | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1492 tty.main.c_cc[VSUSP] = CDISABLE; /* Turn off mips handling of C-z. */ |
491 | 1493 #endif /* VSUSP */ |
1494 #ifdef V_DSUSP | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1495 tty.main.c_cc[V_DSUSP] = CDISABLE; /* Turn off mips handling of C-y. */ |
491 | 1496 #endif /* V_DSUSP */ |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1497 #ifdef VDSUSP /* Some systems have VDSUSP, some have V_DSUSP. */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1498 tty.main.c_cc[VDSUSP] = CDISABLE; |
1102
ff73961932eb
(init_sys_modes): Handle VDSUSP like V_DSUSP.
Richard M. Stallman <rms@gnu.org>
parents:
1048
diff
changeset
|
1499 #endif /* VDSUSP */ |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1500 #ifdef VLNEXT |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1501 tty.main.c_cc[VLNEXT] = CDISABLE; |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1502 #endif /* VLNEXT */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1503 #ifdef VREPRINT |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1504 tty.main.c_cc[VREPRINT] = CDISABLE; |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1505 #endif /* VREPRINT */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1506 #ifdef VWERASE |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1507 tty.main.c_cc[VWERASE] = CDISABLE; |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1508 #endif /* VWERASE */ |
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1509 #ifdef VDISCARD |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1510 tty.main.c_cc[VDISCARD] = CDISABLE; |
3472
6f05f6e83e94
(wait_for_termination): Fix sigpause in POSIX_SIGNALS case.
Richard M. Stallman <rms@gnu.org>
parents:
3334
diff
changeset
|
1511 #endif /* VDISCARD */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1512 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1513 if (tty_out->flow_control) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1514 { |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1515 #ifdef VSTART |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1516 tty.main.c_cc[VSTART] = '\021'; |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1517 #endif /* VSTART */ |
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1518 #ifdef VSTOP |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1519 tty.main.c_cc[VSTOP] = '\023'; |
8104
5434ea918f34
(init_sys_modes): Turn off VSTART and VSTOP chars. On
Richard M. Stallman <rms@gnu.org>
parents:
7908
diff
changeset
|
1520 #endif /* VSTOP */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1521 } |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1522 else |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1523 { |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1524 #ifdef VSTART |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1525 tty.main.c_cc[VSTART] = CDISABLE; |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1526 #endif /* VSTART */ |
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1527 #ifdef VSTOP |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1528 tty.main.c_cc[VSTOP] = CDISABLE; |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1529 #endif /* VSTOP */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1530 } |
491 | 1531 #endif /* mips or HAVE_TCATTR */ |
19198
49274b3596a7
(init_sys_modes) [mips || HAVE_TCATTR]:
Richard M. Stallman <rms@gnu.org>
parents:
19023
diff
changeset
|
1532 |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1533 #ifdef SET_LINE_DISCIPLINE |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1534 /* Need to explicitly request TERMIODISC line discipline or |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1535 Ultrix's termios does not work correctly. */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1536 tty.main.c_line = SET_LINE_DISCIPLINE; |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1537 #endif |
491 | 1538 #ifdef AIX |
1539 #ifndef IBMR2AIX | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1540 /* AIX enhanced edit loses NULs, so disable it. */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1541 tty.main.c_line = 0; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1542 tty.main.c_iflag &= ~ASCEDIT; |
491 | 1543 #else |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1544 tty.main.c_cc[VSTRT] = 255; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1545 tty.main.c_cc[VSTOP] = 255; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1546 tty.main.c_cc[VSUSP] = 255; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1547 tty.main.c_cc[VDSUSP] = 255; |
491 | 1548 #endif /* IBMR2AIX */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1549 if (tty_out->flow_control) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1550 { |
18232
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1551 #ifdef VSTART |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1552 tty.main.c_cc[VSTART] = '\021'; |
18232
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1553 #endif /* VSTART */ |
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1554 #ifdef VSTOP |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1555 tty.main.c_cc[VSTOP] = '\023'; |
18232
4183933733e6
(init_sys_modes): Enable VSTART and VSTOP if flow_control.
Richard M. Stallman <rms@gnu.org>
parents:
18095
diff
changeset
|
1556 #endif /* VSTOP */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1557 } |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1558 /* Also, PTY overloads NUL and BREAK. |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1559 don't ignore break, but don't signal either, so it looks like NUL. |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1560 This really serves a purpose only if running in an XTERM window |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1561 or via TELNET or the like, but does no harm elsewhere. */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1562 tty.main.c_iflag &= ~IGNBRK; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1563 tty.main.c_iflag &= ~BRKINT; |
491 | 1564 #endif |
1565 #else /* if not HAVE_TERMIO */ | |
1566 #ifdef VMS | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1567 tty.main.tt_char |= TT$M_NOECHO; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1568 if (meta_key) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1569 tty.main.tt_char |= TT$M_EIGHTBIT; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1570 if (tty_out->flow_control) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1571 tty.main.tt_char |= TT$M_TTSYNC; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1572 else |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1573 tty.main.tt_char &= ~TT$M_TTSYNC; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1574 tty.main.tt2_char |= TT2$M_PASTHRU | TT2$M_XON; |
491 | 1575 #else /* not VMS (BSD, that is) */ |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
1576 #ifndef DOS_NT |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1577 XSETINT (Vtty_erase_char, tty.main.sg_erase); |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1578 tty.main.sg_flags &= ~(ECHO | CRMOD | XTABS); |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1579 if (meta_key) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1580 tty.main.sg_flags |= ANYP; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1581 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
|
1582 #endif /* not DOS_NT */ |
491 | 1583 #endif /* not VMS (BSD, that is) */ |
1584 #endif /* not HAVE_TERMIO */ | |
1585 | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1586 /* If going to use CBREAK mode, we must request C-g to interrupt |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1587 and turn off start and stop chars, etc. If not going to use |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1588 CBREAK mode, do this anyway so as to turn off local flow |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1589 control for user coming over network on 4.2; in this case, |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1590 only t_stopc and t_startc really matter. */ |
579 | 1591 #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
|
1592 #ifdef HAVE_TCHARS |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1593 /* Note: if not using CBREAK mode, it makes no difference how we |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1594 set this */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1595 tty.tchars = new_tchars; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1596 tty.tchars.t_intrc = quit_char; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1597 if (tty_out->flow_control) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1598 { |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1599 tty.tchars.t_startc = '\021'; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1600 tty.tchars.t_stopc = '\023'; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1601 } |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1602 |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1603 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->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
|
1604 #ifdef ultrix |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1605 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1606 anything, and leaving it in breaks the meta key. Go figure. */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1607 tty.lmode &= ~LLITOUT; |
3759
036367460955
* sysdep.c [ultrix] (init_sys_modes): Don't set LLITOUT; it
Jim Blandy <jimb@redhat.com>
parents:
3695
diff
changeset
|
1608 #endif |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1609 |
579 | 1610 #ifdef BSD4_1 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1611 lmode = tty.lmode; |
579 | 1612 #endif |
1613 | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1614 #endif /* HAVE_TCHARS */ |
579 | 1615 #endif /* not HAVE_TERMIO */ |
1616 | |
3157
84825e357019
* systty.h (HAVE_LTCHARS, HAVE_TCHARS): New macros; define them if
Jim Blandy <jimb@redhat.com>
parents:
3150
diff
changeset
|
1617 #ifdef HAVE_LTCHARS |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1618 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
|
1619 #endif /* HAVE_LTCHARS */ |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1620 #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1621 if (!tty_out->term_initted) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1622 internal_terminal_init (); |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1623 dos_ttraw (); |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1624 #endif |
579 | 1625 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1626 EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), &tty, 0); |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1627 |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1628 /* This code added to insure that, if flow-control is not to be used, |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1629 we have an unlocked terminal at the start. */ |
579 | 1630 |
491 | 1631 #ifdef TCXONC |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1632 if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TCXONC, 1); |
491 | 1633 #endif |
1634 #ifndef APOLLO | |
1635 #ifdef TIOCSTART | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1636 if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TIOCSTART, 0); |
491 | 1637 #endif |
1638 #endif | |
1639 | |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1640 #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
|
1641 #ifdef TCOON |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1642 if (!tty_out->flow_control) tcflow (fileno (TTY_INPUT (tty_out)), TCOON); |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1643 #endif |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
1644 #endif |
9937
cd2db9aeeb25
(init_sys_modes): Maybe call tcflow.
Richard M. Stallman <rms@gnu.org>
parents:
9794
diff
changeset
|
1645 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1646 #ifdef AIXHFT |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1647 hft_init (tty_out); |
491 | 1648 #ifdef IBMR2AIX |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1649 { |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1650 /* IBM's HFT device usually thinks a ^J should be LF/CR. We need it |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1651 to be only LF. This is the way that is done. */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1652 struct termio tty; |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1653 |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1654 if (ioctl (1, HFTGETID, &tty) != -1) |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1655 write (1, "\033[20l", 5); |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1656 } |
491 | 1657 #endif |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1658 #endif /* AIXHFT */ |
491 | 1659 |
1660 #ifdef VMS | |
1661 /* Appears to do nothing when in PASTHRU mode. | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1662 SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, |
491 | 1663 interrupt_signal, oob_chars, 0, 0, 0, 0); |
1664 */ | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1665 queue_kbd_input (0); |
491 | 1666 #endif /* VMS */ |
1667 | |
1668 #ifdef F_SETFL | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1669 #ifndef F_SETOWN_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1670 #ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1671 if (interrupt_input) |
491 | 1672 { |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1673 old_fcntl_owner[fileno (TTY_INPUT (tty_out))] = |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1674 fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1675 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ()); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1676 init_sigio (fileno (TTY_INPUT (tty_out))); |
491 | 1677 } |
1678 #endif /* F_GETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1679 #endif /* F_SETOWN_BUG */ |
491 | 1680 #endif /* F_SETFL */ |
1681 | |
1682 #ifdef BSD4_1 | |
1683 if (interrupt_input) | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1684 init_sigio (fileno (TTY_INPUT (tty_out))); |
491 | 1685 #endif |
1686 | |
1687 #ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ | |
1688 #undef _IOFBF | |
1689 #endif | |
1690 #ifdef _IOFBF | |
1691 /* This symbol is defined on recent USG systems. | |
1692 Someone says without this call USG won't really buffer the file | |
1693 even with a call to setbuf. */ | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1694 setvbuf (TTY_OUTPUT (tty_out), (char *) _sobuf, _IOFBF, sizeof _sobuf); |
491 | 1695 #else |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1696 setbuf (TTY_OUTPUT (tty_out), (char *) _sobuf); |
491 | 1697 #endif |
82995
039bd6989d29
Portability fixes (now it compiles & runs fine on Solaris).
Karoly Lorentey <lorentey@elte.hu>
parents:
82990
diff
changeset
|
1698 |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
1699 tty_set_terminal_modes (tty_out->display); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1700 |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1701 if (!tty_out->term_initted) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1702 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1703 Lisp_Object tail, frame; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1704 FOR_EACH_FRAME (tail, frame) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1705 { |
82990
2ecd1f669db9
Fixed X support, preliminary support for X-tty combo sessions.
Karoly Lorentey <lorentey@elte.hu>
parents:
82989
diff
changeset
|
1706 /* XXX This needs to be revised. */ |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1707 if (FRAME_TERMCAP_P (XFRAME (frame)) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1708 && FRAME_TTY (XFRAME (frame)) == tty_out) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1709 init_frame_faces (XFRAME (frame)); |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1710 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1711 } |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1712 |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1713 if (tty_out->term_initted && no_redraw_on_reenter) |
491 | 1714 { |
1715 if (display_completed) | |
1716 direct_output_forward_char (0); | |
1717 } | |
1718 else | |
1719 { | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1720 Lisp_Object tail, frame; |
766 | 1721 frame_garbaged = 1; |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1722 FOR_EACH_FRAME (tail, frame) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1723 { |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1724 if (FRAME_TERMCAP_P (XFRAME (frame)) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1725 && FRAME_TTY (XFRAME (frame)) == tty_out) |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1726 FRAME_GARBAGED_P (XFRAME (frame)) = 1; |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1727 } |
491 | 1728 } |
579 | 1729 |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1730 tty_out->term_initted = 1; |
491 | 1731 } |
1732 | |
1733 /* Return nonzero if safe to use tabs in output. | |
1734 At the time this is called, init_sys_modes has not been done yet. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1735 |
21514 | 1736 int |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1737 tabs_safe_p (int fd) |
491 | 1738 { |
53232
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
1739 struct emacs_tty etty; |
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
1740 |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1741 EMACS_GET_TTY (fd, &etty); |
53232
22aaf1e5fbe6
Full support for multiple terminal I/O (with some rough edges).
Karoly Lorentey <lorentey@elte.hu>
parents:
53231
diff
changeset
|
1742 return EMACS_TTY_TABS_OK (&etty); |
491 | 1743 } |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1744 |
491 | 1745 /* Get terminal size from system. |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1746 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
|
1747 We store 0 if there's no valid information. */ |
491 | 1748 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1749 void |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1750 get_tty_size (int fd, int *widthp, int *heightp) |
491 | 1751 { |
579 | 1752 |
1753 #ifdef TIOCGWINSZ | |
1754 | |
1755 /* BSD-style. */ | |
1756 struct winsize size; | |
1757 | |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1758 if (ioctl (fd, TIOCGWINSZ, &size) == -1) |
579 | 1759 *widthp = *heightp = 0; |
1760 else | |
1761 { | |
1762 *widthp = size.ws_col; | |
1763 *heightp = size.ws_row; | |
1764 } | |
1765 | |
1766 #else | |
491 | 1767 #ifdef TIOCGSIZE |
579 | 1768 |
1769 /* SunOS - style. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1770 struct ttysize size; |
579 | 1771 |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1772 if (ioctl (fd, TIOCGSIZE, &size) == -1) |
579 | 1773 *widthp = *heightp = 0; |
1774 else | |
1775 { | |
1776 *widthp = size.ts_cols; | |
1777 *heightp = size.ts_lines; | |
1778 } | |
1779 | |
1780 #else | |
491 | 1781 #ifdef VMS |
579 | 1782 |
1783 struct sensemode tty; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1784 |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1785 SYS$QIOW (0, fd, IO$_SENSEMODE, &tty, 0, 0, |
491 | 1786 &tty.class, 12, 0, 0, 0, 0); |
1787 *widthp = tty.scr_wid; | |
1788 *heightp = tty.scr_len; | |
579 | 1789 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1790 #else |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1791 #ifdef MSDOS |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1792 *widthp = ScreenCols (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1793 *heightp = ScreenRows (); |
491 | 1794 #else /* system doesn't know size */ |
1795 *widthp = 0; | |
1796 *heightp = 0; | |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1797 #endif |
579 | 1798 #endif /* not VMS */ |
1799 #endif /* not SunOS-style */ | |
1800 #endif /* not BSD-style */ | |
491 | 1801 } |
579 | 1802 |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1803 /* 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
|
1804 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
|
1805 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1806 int |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1807 set_window_size (fd, height, width) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1808 int fd, height, width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1809 { |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1810 #ifdef TIOCSWINSZ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1811 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1812 /* BSD-style. */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1813 struct winsize size; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1814 size.ws_row = height; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1815 size.ws_col = width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1816 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1817 if (ioctl (fd, TIOCSWINSZ, &size) == -1) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1818 return 0; /* error */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1819 else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1820 return 1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1821 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1822 #else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1823 #ifdef TIOCSSIZE |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1824 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1825 /* SunOS - style. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1826 struct ttysize size; |
6829
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1827 size.ts_lines = height; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1828 size.ts_cols = width; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1829 |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1830 if (ioctl (fd, TIOCGSIZE, &size) == -1) |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1831 return 0; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1832 else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1833 return 1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1834 #else |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1835 return -1; |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1836 #endif /* not SunOS-style */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1837 #endif /* not BSD-style */ |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1838 } |
684201f9fa7f
(set_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6799
diff
changeset
|
1839 |
491 | 1840 |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1841 |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1842 /* Prepare all terminal devices for exiting Emacs. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1843 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1844 void |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1845 reset_all_sys_modes (void) |
491 | 1846 { |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
1847 struct tty_display_info *tty; |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1848 for (tty = tty_list; tty; tty = tty->next) |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1849 reset_sys_modes (tty); |
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1850 } |
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
1851 |
53341 | 1852 /* Prepare the terminal for closing it; move the cursor to the |
766 | 1853 bottom of the frame, turn off interrupt-driven I/O, etc. */ |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1854 |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1855 void |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1856 reset_sys_modes (tty_out) |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
1857 struct tty_display_info *tty_out; |
491 | 1858 { |
1859 if (noninteractive) | |
1860 { | |
1861 fflush (stdout); | |
1862 return; | |
1863 } | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1864 if (!tty_out->term_initted) |
491 | 1865 return; |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1866 |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1867 /* Go to and clear the last line of the terminal. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1868 |
53341 | 1869 cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
83025
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1870 |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1871 /* Code adapted from tty_clear_end_of_line. */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1872 if (tty_out->TS_clr_line) |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1873 { |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1874 emacs_tputs (tty_out, tty_out->TS_clr_line, 1, cmputc); |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1875 } |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1876 else |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1877 { /* have to do it the hard way */ |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1878 int i; |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1879 turn_off_insert (tty_out); |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1880 |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1881 for (i = curX (tty_out); i < FrameCols (tty_out) - 1; i++) |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1882 { |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1883 fputc (' ', TTY_OUTPUT (tty_out)); |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1884 } |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1885 } |
c66ebcc29777
Removed %T in mode-line-format. Trivial documentation changes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83014
diff
changeset
|
1886 |
53341 | 1887 cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1888 fflush (tty_out->output); |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1889 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1890 #if defined (IBMR2AIX) && defined (AIXHFT) |
491 | 1891 { |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1892 /* HFT devices normally use ^J as a LF/CR. We forced it to |
491 | 1893 do the LF only. Now, we need to reset it. */ |
1894 struct termio tty; | |
1895 | |
1896 if (ioctl (1, HFTGETID, &tty) != -1) | |
1897 write (1, "\033[20h", 5); | |
1898 } | |
1899 #endif | |
1900 | |
83008
040dd41ed7d0
Hookified termcap devices, added bootstrap display device, plus many bugfixes.
Karoly Lorentey <lorentey@elte.hu>
parents:
83004
diff
changeset
|
1901 tty_reset_terminal_modes (tty_out->display); |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1902 fflush (TTY_OUTPUT (tty_out)); |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
1903 #ifdef BSD_SYSTEM |
491 | 1904 #ifndef BSD4_1 |
1905 /* Avoid possible loss of output when changing terminal modes. */ | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1906 fsync (fileno (TTY_OUTPUT (tty_out))); |
491 | 1907 #endif |
1908 #endif | |
579 | 1909 |
491 | 1910 #ifdef F_SETFL |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1911 #ifndef F_SETOWN_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
1912 #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ |
491 | 1913 if (interrupt_input) |
1914 { | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1915 reset_sigio (fileno (TTY_INPUT (tty_out))); |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1916 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1917 old_fcntl_owner[fileno (TTY_INPUT (tty_out))]); |
491 | 1918 } |
1919 #endif /* F_SETOWN */ | |
4142
6cdfdbe5058b
* xterm.c, sysdep.c (F_SETOWN_BUG): Defined.
Jim Blandy <jimb@redhat.com>
parents:
3842
diff
changeset
|
1920 #endif /* F_SETOWN_BUG */ |
6489
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1921 #ifdef O_NDELAY |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1922 fcntl (fileno (TTY_INPUT (tty_out)), F_SETFL, |
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1923 fcntl (fileno (TTY_INPUT (tty_out)), F_GETFL, 0) & ~O_NDELAY); |
6489
6c138b61c8b4
(reset_sys_modes): Turn off O_NDELAY.
Karl Heuer <kwzh@gnu.org>
parents:
6102
diff
changeset
|
1924 #endif |
491 | 1925 #endif /* F_SETFL */ |
1926 #ifdef BSD4_1 | |
1927 if (interrupt_input) | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
1928 reset_sigio (fileno (TTY_INPUT (tty_out))); |
491 | 1929 #endif /* BSD4_1 */ |
579 | 1930 |
53233
fe9b37bee5f7
Fully eliminated global tty state variables.
Karoly Lorentey <lorentey@elte.hu>
parents:
53232
diff
changeset
|
1931 if (tty_out->old_tty) |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1932 while (EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), |
53233
fe9b37bee5f7
Fully eliminated global tty state variables.
Karoly Lorentey <lorentey@elte.hu>
parents:
53232
diff
changeset
|
1933 tty_out->old_tty, 0) < 0 && errno == EINTR) |
12070 | 1934 ; |
491 | 1935 |
5498
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1936 #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
|
1937 dos_ttcooked (); |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1938 #endif |
636e4507b52b
[MSDOS]: #include <dos.h>, "dosfns.h", "msdos.h", and
Richard M. Stallman <rms@gnu.org>
parents:
5420
diff
changeset
|
1939 |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1940 #ifdef SET_LINE_DISCIPLINE |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1941 /* 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
|
1942 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
|
1943 Restore the old line discipline by hand. */ |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
1944 ioctl (0, TIOCSETD, &tty_out->old_tty.main.c_line); |
10108
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1945 #endif |
2844db63605f
(child_setup_tty): Use CDISABLE for setting VERASE, VKILL.
Richard M. Stallman <rms@gnu.org>
parents:
10049
diff
changeset
|
1946 |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
1947 #ifdef AIXHFT |
491 | 1948 hft_reset (); |
1949 #endif | |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1950 |
5964
1b850ec1a5e2
(init_sys_modes, reset_sys_modes): Test BSD_PGRPS.
Richard M. Stallman <rms@gnu.org>
parents:
5960
diff
changeset
|
1951 #ifdef BSD_PGRPS |
82987
1682917e56b4
Major bugfixes and slight enhancements.
Karoly Lorentey <lorentey@elte.hu>
parents:
82986
diff
changeset
|
1952 widen_foreground_group (fileno (TTY_INPUT (tty_out))); |
3655
3e6cc11cfe9f
Interact properly with shells lacking job control (sh, rc, es...)
Jim Blandy <jimb@redhat.com>
parents:
3604
diff
changeset
|
1953 #endif |
491 | 1954 } |
1955 | |
1956 #ifdef HAVE_PTYS | |
1957 | |
1958 /* Set up the proper status flags for use of a pty. */ | |
1959 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
1960 void |
491 | 1961 setup_pty (fd) |
1962 int fd; | |
1963 { | |
1964 /* I'm told that TOICREMOTE does not mean control chars | |
1965 "can't be sent" but rather that they don't have | |
1966 input-editing or signaling effects. | |
1967 That should be good, because we have other ways | |
1968 to do those things in Emacs. | |
1969 However, telnet mode seems not to work on 4.2. | |
1970 So TIOCREMOTE is turned off now. */ | |
1971 | |
1972 /* Under hp-ux, if TIOCREMOTE is turned on, some calls | |
1973 will hang. In particular, the "timeout" feature (which | |
1974 causes a read to return if there is no data available) | |
1975 does this. Also it is known that telnet mode will hang | |
1976 in such a way that Emacs must be stopped (perhaps this | |
1977 is the same problem). | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1978 |
491 | 1979 If TIOCREMOTE is turned off, then there is a bug in |
1980 hp-ux which sometimes loses data. Apparently the | |
1981 code which blocks the master process when the internal | |
1982 buffer fills up does not work. Other than this, | |
1983 though, everything else seems to work fine. | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
1984 |
491 | 1985 Since the latter lossage is more benign, we may as well |
1986 lose that way. -- cph */ | |
1987 #ifdef FIONBIO | |
29033
bad1d68a57e3
(setup_pty): Treat case that UNIX98_PTYS is defined
Gerd Moellmann <gerd@gnu.org>
parents:
27933
diff
changeset
|
1988 #if defined(SYSV_PTYS) || defined(UNIX98_PTYS) |
491 | 1989 { |
1990 int on = 1; | |
1991 ioctl (fd, FIONBIO, &on); | |
1992 } | |
1993 #endif | |
1994 #endif | |
1995 #ifdef IBMRTAIX | |
1996 /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */ | |
1997 /* ignore SIGHUP once we've started a child on a pty. Note that this may */ | |
1998 /* cause EMACS not to die when it should, i.e., when its own controlling */ | |
1999 /* tty goes away. I've complained to the AIX developers, and they may */ | |
2000 /* change this behavior, but I'm not going to hold my breath. */ | |
2001 signal (SIGHUP, SIG_IGN); | |
2002 #endif | |
2003 } | |
2004 #endif /* HAVE_PTYS */ | |
2005 | |
2006 #ifdef VMS | |
2007 | |
2008 /* Assigning an input channel is done at the start of Emacs execution. | |
2009 This is called each time Emacs is resumed, also, but does nothing | |
2010 because input_chain is no longer zero. */ | |
2011 | |
21514 | 2012 void |
491 | 2013 init_vms_input () |
2014 { | |
2015 int status; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2016 |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
2017 if (fileno (TTY_INPUT (CURTTY())) == 0) |
491 | 2018 { |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
2019 status = SYS$ASSIGN (&input_dsc, &fileno (TTY_INPUT (CURTTY())), 0, 0); |
491 | 2020 if (! (status & 1)) |
2021 LIB$STOP (status); | |
2022 } | |
2023 } | |
2024 | |
2025 /* Deassigning the input channel is done before exiting. */ | |
2026 | |
21514 | 2027 void |
491 | 2028 stop_vms_input () |
2029 { | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
2030 return SYS$DASSGN (fileno (TTY_INPUT (CURTTY()))); |
491 | 2031 } |
2032 | |
2033 short input_buffer; | |
2034 | |
2035 /* Request reading one character into the keyboard buffer. | |
2036 This is done as soon as the buffer becomes empty. */ | |
2037 | |
21514 | 2038 void |
491 | 2039 queue_kbd_input () |
2040 { | |
2041 int status; | |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
2042 extern kbd_input_ast (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
2043 |
491 | 2044 waiting_for_ast = 0; |
2045 stop_input = 0; | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
2046 status = SYS$QIO (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK, |
491 | 2047 &input_iosb, kbd_input_ast, 1, |
2048 &input_buffer, 1, 0, terminator_mask, 0, 0); | |
2049 } | |
2050 | |
2051 int input_count; | |
2052 | |
2053 /* Ast routine that is called when keyboard input comes in | |
2054 in accord with the SYS$QIO above. */ | |
2055 | |
21514 | 2056 void |
491 | 2057 kbd_input_ast () |
2058 { | |
2059 register int c = -1; | |
2060 int old_errno = errno; | |
648 | 2061 extern EMACS_TIME *input_available_clear_time; |
491 | 2062 |
2063 if (waiting_for_ast) | |
2064 SYS$SETEF (input_ef); | |
2065 waiting_for_ast = 0; | |
2066 input_count++; | |
2067 #ifdef ASTDEBUG | |
2068 if (input_count == 25) | |
2069 exit (1); | |
2070 printf ("Ast # %d,", input_count); | |
2071 printf (" iosb = %x, %x, %x, %x", | |
2072 input_iosb.offset, input_iosb.status, input_iosb.termlen, | |
2073 input_iosb.term); | |
2074 #endif | |
2075 if (input_iosb.offset) | |
2076 { | |
2077 c = input_buffer; | |
2078 #ifdef ASTDEBUG | |
2079 printf (", char = 0%o", c); | |
2080 #endif | |
2081 } | |
2082 #ifdef ASTDEBUG | |
2083 printf ("\n"); | |
2084 fflush (stdout); | |
2085 sleep (1); | |
2086 #endif | |
2087 if (! stop_input) | |
2088 queue_kbd_input (); | |
2089 if (c >= 0) | |
2090 { | |
2091 struct input_event e; | |
51572
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2092 EVENT_INIT (e); |
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2093 |
45804 | 2094 e.kind = ASCII_KEYSTROKE_EVENT; |
9279
2382e2f3884e
(kbd_input_ast, read_input_waiting): Use new accessor macros instead of
Karl Heuer <kwzh@gnu.org>
parents:
9239
diff
changeset
|
2095 XSETINT (e.code, c); |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
2096 e.frame_or_window = selected_frame; |
491 | 2097 kbd_buffer_store_event (&e); |
2098 } | |
648 | 2099 if (input_available_clear_time) |
2100 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); | |
491 | 2101 errno = old_errno; |
2102 } | |
2103 | |
2104 /* Wait until there is something in kbd_buffer. */ | |
2105 | |
21514 | 2106 void |
491 | 2107 wait_for_kbd_input () |
2108 { | |
2109 extern int have_process_input, process_exited; | |
2110 | |
2111 /* If already something, avoid doing system calls. */ | |
2112 if (detect_input_pending ()) | |
2113 { | |
2114 return; | |
2115 } | |
2116 /* Clear a flag, and tell ast routine above to set it. */ | |
2117 SYS$CLREF (input_ef); | |
2118 waiting_for_ast = 1; | |
2119 /* Check for timing error: ast happened while we were doing that. */ | |
2120 if (!detect_input_pending ()) | |
2121 { | |
2122 /* No timing error: wait for flag to be set. */ | |
2123 set_waiting_for_input (0); | |
2124 SYS$WFLOR (input_ef, input_eflist); | |
41163
c8f21aec2f62
(wait_for_kbd_input) [VMS]: Do not call clear_waiting_for_input with
Pavel Janík <Pavel@Janik.cz>
parents:
40932
diff
changeset
|
2125 clear_waiting_for_input (); |
491 | 2126 if (!detect_input_pending ()) |
2127 /* Check for subprocess input availability */ | |
2128 { | |
2129 int dsp = have_process_input || process_exited; | |
2130 | |
2131 SYS$CLREF (process_ef); | |
2132 if (have_process_input) | |
2133 process_command_input (); | |
2134 if (process_exited) | |
2135 process_exit (); | |
2136 if (dsp) | |
2137 { | |
2138 update_mode_lines++; | |
5253
1846f03ac8f3
[VMS] (wait_for_kbd_input): Call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
5189
diff
changeset
|
2139 prepare_menu_bars (); |
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
35189
diff
changeset
|
2140 redisplay_preserve_echo_area (18); |
491 | 2141 } |
2142 } | |
2143 } | |
2144 waiting_for_ast = 0; | |
2145 } | |
2146 | |
2147 /* Get rid of any pending QIO, when we are about to suspend | |
2148 or when we want to throw away pending input. | |
2149 We wait for a positive sign that the AST routine has run | |
2150 and therefore there is no I/O request queued when we return. | |
2151 SYS$SETAST is used to avoid a timing error. */ | |
2152 | |
21514 | 2153 void |
491 | 2154 end_kbd_input () |
2155 { | |
2156 #ifdef ASTDEBUG | |
2157 printf ("At end_kbd_input.\n"); | |
2158 fflush (stdout); | |
2159 sleep (1); | |
2160 #endif | |
2161 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ | |
2162 { | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
2163 SYS$CANCEL (fileno (TTY_INPUT (CURTTY()))); |
491 | 2164 return; |
2165 } | |
2166 | |
2167 SYS$SETAST (0); | |
2168 /* Clear a flag, and tell ast routine above to set it. */ | |
2169 SYS$CLREF (input_ef); | |
2170 waiting_for_ast = 1; | |
2171 stop_input = 1; | |
53229
33c3c7c16e13
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
Karoly Lorentey <lorentey@elte.hu>
parents:
53226
diff
changeset
|
2172 SYS$CANCEL (fileno (TTY_INPUT (CURTTY()))); |
491 | 2173 SYS$SETAST (1); |
2174 SYS$WAITFR (input_ef); | |
2175 waiting_for_ast = 0; | |
2176 } | |
2177 | |
2178 /* Wait for either input available or time interval expiry. */ | |
2179 | |
21514 | 2180 void |
491 | 2181 input_wait_timeout (timeval) |
2182 int timeval; /* Time to wait, in seconds */ | |
2183 { | |
2184 int time [2]; | |
2185 static int zero = 0; | |
2186 static int large = -10000000; | |
2187 | |
2188 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ | |
2189 | |
2190 /* If already something, avoid doing system calls. */ | |
2191 if (detect_input_pending ()) | |
2192 { | |
2193 return; | |
2194 } | |
2195 /* Clear a flag, and tell ast routine above to set it. */ | |
2196 SYS$CLREF (input_ef); | |
2197 waiting_for_ast = 1; | |
2198 /* Check for timing error: ast happened while we were doing that. */ | |
2199 if (!detect_input_pending ()) | |
2200 { | |
2201 /* No timing error: wait for flag to be set. */ | |
2202 SYS$CANTIM (1, 0); | |
2203 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
2204 SYS$WFLOR (timer_ef, timer_eflist); /* Wait for timer expiry or input */ | |
2205 } | |
2206 waiting_for_ast = 0; | |
2207 } | |
2208 | |
2209 /* The standard `sleep' routine works some other way | |
2210 and it stops working if you have ever quit out of it. | |
2211 This one continues to work. */ | |
2212 | |
2213 sys_sleep (timeval) | |
2214 int timeval; | |
2215 { | |
2216 int time [2]; | |
2217 static int zero = 0; | |
2218 static int large = -10000000; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2219 |
491 | 2220 LIB$EMUL (&timeval, &large, &zero, time); /* Convert to VMS format */ |
2221 | |
2222 SYS$CANTIM (1, 0); | |
2223 if (SYS$SETIMR (timer_ef, time, 0, 1) & 1) /* Set timer */ | |
2224 SYS$WAITFR (timer_ef); /* Wait for timer expiry only */ | |
2225 } | |
2226 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2227 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2228 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2229 int fd; |
491 | 2230 { |
2231 request_sigio (); | |
2232 } | |
2233 | |
53341 | 2234 reset_sigio (fd) |
2235 int fd; | |
491 | 2236 { |
2237 unrequest_sigio (); | |
2238 } | |
2239 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2240 void |
491 | 2241 request_sigio () |
2242 { | |
2243 croak ("request sigio"); | |
2244 } | |
2245 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2246 void |
491 | 2247 unrequest_sigio () |
2248 { | |
2249 croak ("unrequest sigio"); | |
2250 } | |
2251 | |
2252 #endif /* VMS */ | |
2253 | |
2254 /* Note that VMS compiler won't accept defined (CANNOT_DUMP). */ | |
2255 #ifndef CANNOT_DUMP | |
2256 #define NEED_STARTS | |
2257 #endif | |
2258 | |
2259 #ifndef SYSTEM_MALLOC | |
2260 #ifndef NEED_STARTS | |
2261 #define NEED_STARTS | |
2262 #endif | |
2263 #endif | |
2264 | |
2265 #ifdef NEED_STARTS | |
2266 /* Some systems that cannot dump also cannot implement these. */ | |
2267 | |
2268 /* | |
2269 * Return the address of the start of the text segment prior to | |
2270 * doing an unexec. After unexec the return value is undefined. | |
2271 * See crt0.c for further explanation and _start. | |
2272 * | |
2273 */ | |
2274 | |
27922
db5a4af9fafd
(start_of_text): Don't define this function for NetBSD
Gerd Moellmann <gerd@gnu.org>
parents:
27709
diff
changeset
|
2275 #if !(defined (__NetBSD__) && defined (__ELF__)) |
9039
22e5c594d59d
(start_of_text): Don't test CANNOT_UNEXEC.
Richard M. Stallman <rms@gnu.org>
parents:
9036
diff
changeset
|
2276 #ifndef HAVE_TEXT_START |
491 | 2277 char * |
2278 start_of_text () | |
2279 { | |
2280 #ifdef TEXT_START | |
2281 return ((char *) TEXT_START); | |
2282 #else | |
2283 #ifdef GOULD | |
2284 extern csrt (); | |
2285 return ((char *) csrt); | |
2286 #else /* not GOULD */ | |
2287 extern int _start (); | |
2288 return ((char *) _start); | |
2289 #endif /* GOULD */ | |
2290 #endif /* TEXT_START */ | |
2291 } | |
9039
22e5c594d59d
(start_of_text): Don't test CANNOT_UNEXEC.
Richard M. Stallman <rms@gnu.org>
parents:
9036
diff
changeset
|
2292 #endif /* not HAVE_TEXT_START */ |
27922
db5a4af9fafd
(start_of_text): Don't define this function for NetBSD
Gerd Moellmann <gerd@gnu.org>
parents:
27709
diff
changeset
|
2293 #endif |
491 | 2294 |
2295 /* | |
2296 * Return the address of the start of the data segment prior to | |
2297 * doing an unexec. After unexec the return value is undefined. | |
2298 * See crt0.c for further information and definition of data_start. | |
2299 * | |
2300 * Apparently, on BSD systems this is etext at startup. On | |
2301 * USG systems (swapping) this is highly mmu dependent and | |
2302 * is also dependent on whether or not the program is running | |
2303 * with shared text. Generally there is a (possibly large) | |
2304 * gap between end of text and start of data with shared text. | |
2305 * | |
2306 * On Uniplus+ systems with shared text, data starts at a | |
2307 * fixed address. Each port (from a given oem) is generally | |
2308 * different, and the specific value of the start of data can | |
2309 * be obtained via the UniPlus+ specific "uvar" system call, | |
2310 * however the method outlined in crt0.c seems to be more portable. | |
2311 * | |
2312 * Probably what will have to happen when a USG unexec is available, | |
2313 * at least on UniPlus, is temacs will have to be made unshared so | |
2314 * that text and data are contiguous. Then once loadup is complete, | |
2315 * 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
|
2316 * at the normal shared text boundary and the startofdata variable |
491 | 2317 * will be patched by unexec to the correct value. |
2318 * | |
2319 */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2320 |
46653
8ba889cb6430
(start_of_data): Don't define the function if a macro
Ken Raeburn <raeburn@raeburn.org>
parents:
46591
diff
changeset
|
2321 #ifndef start_of_data |
491 | 2322 char * |
2323 start_of_data () | |
2324 { | |
2325 #ifdef DATA_START | |
2326 return ((char *) DATA_START); | |
2327 #else | |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2328 #ifdef ORDINARY_LINK |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2329 /* |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2330 * 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
|
2331 * 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
|
2332 * 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
|
2333 * 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
|
2334 */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2335 extern char **environ; |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2336 |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
2337 return ((char *) &environ); |
2121
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2338 #else |
491 | 2339 extern int data_start; |
2340 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
|
2341 #endif /* ORDINARY_LINK */ |
ebc56bb13048
* sysdep.c (read_input_waiting): Set e.frame_or_window, not
Jim Blandy <jimb@redhat.com>
parents:
1927
diff
changeset
|
2342 #endif /* DATA_START */ |
491 | 2343 } |
46653
8ba889cb6430
(start_of_data): Don't define the function if a macro
Ken Raeburn <raeburn@raeburn.org>
parents:
46591
diff
changeset
|
2344 #endif /* start_of_data */ |
491 | 2345 #endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */ |
2346 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2347 /* 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
|
2348 system-name to return. */ |
491 | 2349 |
2350 #ifdef BSD4_1 | |
2351 #include <whoami.h> | |
2352 #endif | |
2353 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2354 extern Lisp_Object Vsystem_name; |
491 | 2355 |
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2356 #ifndef BSD4_1 |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2357 #ifndef VMS |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2358 #ifdef HAVE_SOCKETS |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2359 #include <sys/socket.h> |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2360 #include <netdb.h> |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2361 #endif /* HAVE_SOCKETS */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2362 #endif /* not VMS */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2363 #endif /* not BSD4_1 */ |
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2364 |
33718
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2365 #ifdef TRY_AGAIN |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2366 #ifndef HAVE_H_ERRNO |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2367 extern int h_errno; |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2368 #endif |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2369 #endif /* TRY_AGAIN */ |
79a269bdf047
Move the code for declaring h_errno after #include <netdb.h>.
Kenichi Handa <handa@m17n.org>
parents:
33617
diff
changeset
|
2370 |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2371 void |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2372 init_system_name () |
491 | 2373 { |
2374 #ifdef BSD4_1 | |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2375 Vsystem_name = build_string (sysname); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2376 #else |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2377 #ifdef VMS |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2378 char *sp, *end; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2379 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
|
2380 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
|
2381 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
|
2382 Vsystem_name = build_string (sp); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2383 else |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2384 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
|
2385 #else |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2386 #ifndef HAVE_GETHOSTNAME |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2387 struct utsname uts; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2388 uname (&uts); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2389 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
|
2390 #else /* HAVE_GETHOSTNAME */ |
11800
a2f009e1b85b
(init_system_name): Clean up signedness mismatch.
Karl Heuer <kwzh@gnu.org>
parents:
11722
diff
changeset
|
2391 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
|
2392 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
|
2393 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2394 /* 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
|
2395 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
|
2396 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
|
2397 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
|
2398 for (;;) |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2399 { |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2400 gethostname (hostname, hostname_size - 1); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2401 hostname[hostname_size - 1] = '\0'; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2402 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2403 /* 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
|
2404 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
|
2405 break; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2406 |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2407 hostname_size <<= 1; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2408 hostname = (char *) alloca (hostname_size); |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2409 } |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2410 #ifdef HAVE_SOCKETS |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2411 /* 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
|
2412 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
|
2413 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
|
2414 #ifndef CANNOT_DUMP |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2415 if (initialized) |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2416 #endif /* not CANNOT_DUMP */ |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2417 if (! index (hostname, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2418 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2419 struct hostent *hp; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2420 int count; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2421 for (count = 0;; count++) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2422 { |
8330
60adc323cfe7
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8285
diff
changeset
|
2423 #ifdef TRY_AGAIN |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2424 h_errno = 0; |
8330
60adc323cfe7
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8285
diff
changeset
|
2425 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2426 hp = gethostbyname (hostname); |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
2427 #ifdef TRY_AGAIN |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2428 if (! (hp == 0 && h_errno == TRY_AGAIN)) |
8285
6609af160f16
(init_system_name): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8104
diff
changeset
|
2429 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2430 break; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2431 if (count >= 5) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2432 break; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2433 Fsleep_for (make_number (1), Qnil); |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2434 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2435 if (hp) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2436 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2437 char *fqdn = (char *) hp->h_name; |
43177
de51098df2fd
(init_system_name): Put unused variable `p' in #if 0.
Pavel Janík <Pavel@Janik.cz>
parents:
42469
diff
changeset
|
2438 #if 0 |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2439 char *p; |
43177
de51098df2fd
(init_system_name): Put unused variable `p' in #if 0.
Pavel Janík <Pavel@Janik.cz>
parents:
42469
diff
changeset
|
2440 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2441 |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2442 if (!index (fqdn, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2443 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2444 /* We still don't have a fully qualified domain name. |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2445 Try to find one in the list of alternate names */ |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2446 char **alias = hp->h_aliases; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2447 while (*alias && !index (*alias, '.')) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2448 alias++; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2449 if (*alias) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2450 fqdn = *alias; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2451 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2452 hostname = fqdn; |
6799 | 2453 #if 0 |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2454 /* Convert the host name to lower case. */ |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2455 /* Using ctype.h here would introduce a possible locale |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2456 dependence that is probably wrong for hostnames. */ |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2457 p = hostname; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2458 while (*p) |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2459 { |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2460 if (*p >= 'A' && *p <= 'Z') |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2461 *p += 'a' - 'A'; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2462 p++; |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2463 } |
6799 | 2464 #endif |
20202
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2465 } |
de9483a63b12
(init_system_name): If gethostname gives a proper
Karl Heuer <kwzh@gnu.org>
parents:
19699
diff
changeset
|
2466 } |
3150
afc59d5d30c6
[HAVE_SOCKETS]: Include socket.h, netdb.h.
Richard M. Stallman <rms@gnu.org>
parents:
3106
diff
changeset
|
2467 #endif /* HAVE_SOCKETS */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2468 /* We used to try using getdomainname here, |
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2469 but NIIBE Yutaka <gniibe@etl.go.jp> says that |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2470 getdomainname gets the NIS/YP domain which often is not the same |
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2471 as in Internet domain name. */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2472 #if 0 /* Turned off because sysinfo is not really likely to return the |
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2473 correct Internet domain. */ |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2474 #if (HAVE_SYSINFO && defined (SI_SRPC_DOMAIN)) |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2475 if (! index (hostname, '.')) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2476 { |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2477 /* The hostname is not fully qualified. Append the domain name. */ |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2478 |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2479 int hostlen = strlen (hostname); |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2480 int domain_size = 256; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2481 |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2482 for (;;) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2483 { |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2484 char *domain = (char *) alloca (domain_size + 1); |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2485 char *fqdn = (char *) alloca (hostlen + 1 + domain_size + 1); |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2486 int sys_domain_size = sysinfo (SI_SRPC_DOMAIN, domain, domain_size); |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2487 if (sys_domain_size <= 0) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2488 break; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2489 if (domain_size < sys_domain_size) |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2490 { |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2491 domain_size = sys_domain_size; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2492 continue; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2493 } |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2494 strcpy (fqdn, hostname); |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2495 if (domain[0] == '.') |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2496 strcpy (fqdn + hostlen, domain); |
19258
cf4b06e6a5ab
(init_system_name): If domain is null, don't add a period.
Richard M. Stallman <rms@gnu.org>
parents:
19198
diff
changeset
|
2497 else if (domain[0] != 0) |
18660
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2498 { |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2499 fqdn[hostlen] = '.'; |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2500 strcpy (fqdn + hostlen + 1, domain); |
42cf8e9273ee
(ospeed): Define as short, unless HAVE_TERMIOS_H and LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2501 } |
16003
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2502 hostname = fqdn; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2503 break; |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2504 } |
96349e2b7511
(<sys/systeminfo.h>): Include if HAVE_SYS_SYSTEMINFO_H is defined.
Paul Eggert <eggert@twinsun.com>
parents:
15718
diff
changeset
|
2505 } |
19639
fb3c3590498e
(init_system_name): Don't try to use getdomainname.
Richard M. Stallman <rms@gnu.org>
parents:
19258
diff
changeset
|
2506 #endif /* HAVE_SYSINFO && defined (SI_SRPC_DOMAIN) */ |
20293
31035eff741a
(init_system_name): Don't use sysinfo.
Karl Heuer <kwzh@gnu.org>
parents:
20288
diff
changeset
|
2507 #endif /* 0 */ |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2508 Vsystem_name = build_string (hostname); |
5734
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2509 #endif /* HAVE_GETHOSTNAME */ |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2510 #endif /* VMS */ |
3c8ae6c720d8
(get_system_name): Remove restriction on hostname size.
Karl Heuer <kwzh@gnu.org>
parents:
5682
diff
changeset
|
2511 #endif /* BSD4_1 */ |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2512 { |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2513 unsigned char *p; |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
46298
diff
changeset
|
2514 for (p = SDATA (Vsystem_name); *p; p++) |
7908
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2515 if (*p == ' ' || *p == '\t') |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2516 *p = '-'; |
2d605a73a1fd
(init_system_name): New function, replaces get_system_name.
Karl Heuer <kwzh@gnu.org>
parents:
7889
diff
changeset
|
2517 } |
491 | 2518 } |
2519 | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
2520 #ifndef MSDOS |
491 | 2521 #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
|
2522 #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
|
2523 |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2524 #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
|
2525 #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
|
2526 |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2527 #if defined (HAVE_X_WINDOWS) && !defined (HAVE_SELECT) |
491 | 2528 /* Cause explanatory error message at compile time, |
2529 since the select emulation is not good enough for X. */ | |
2530 int *x = &x_windows_lose_if_no_select_system_call; | |
2531 #endif | |
2532 | |
2533 /* Emulate as much as select as is possible under 4.1 and needed by Gnu Emacs | |
2534 * Only checks read descriptors. | |
2535 */ | |
2536 /* How long to wait between checking fds in select */ | |
2537 #define SELECT_PAUSE 1 | |
2538 int select_alarmed; | |
2539 | |
2540 /* For longjmp'ing back to read_input_waiting. */ | |
2541 | |
2542 jmp_buf read_alarm_throw; | |
2543 | |
2544 /* Nonzero if the alarm signal should throw back to read_input_waiting. | |
2545 The read_socket_hook function sets this to 1 while it is waiting. */ | |
2546 | |
2547 int read_alarm_should_throw; | |
2548 | |
2549 SIGTYPE | |
2550 select_alarm () | |
2551 { | |
2552 select_alarmed = 1; | |
2553 #ifdef BSD4_1 | |
2554 sigrelse (SIGALRM); | |
2555 #else /* not BSD4_1 */ | |
2556 signal (SIGALRM, SIG_IGN); | |
2557 #endif /* not BSD4_1 */ | |
2558 if (read_alarm_should_throw) | |
2559 longjmp (read_alarm_throw, 1); | |
2560 } | |
2561 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
2562 #ifndef WINDOWSNT |
491 | 2563 /* Only rfds are checked. */ |
2564 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
|
2565 sys_select (nfds, rfds, wfds, efds, timeout) |
491 | 2566 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
|
2567 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
|
2568 EMACS_TIME *timeout; |
491 | 2569 { |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
2570 /* XXX This needs to be updated for multi-tty support. Is there |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
2571 anybody who needs to emulate select these days? */ |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
2572 int ravail = 0; |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2573 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
|
2574 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
|
2575 int *local_timeout; |
491 | 2576 extern int proc_buffered_char[]; |
2577 #ifndef subprocesses | |
2578 int process_tick = 0, update_tick = 0; | |
2579 #else | |
2580 extern int process_tick, update_tick; | |
2581 #endif | |
2582 unsigned char buf; | |
2583 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2584 #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
|
2585 /* 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
|
2586 emulation for non-X usage. */ |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
2587 if (!NILP (Vinitial_window_system)) |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2588 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
|
2589 #endif |
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2590 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
|
2591 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
|
2592 FD_ZERO (&orfds); |
491 | 2593 if (rfds) |
2594 { | |
2595 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
|
2596 FD_ZERO (rfds); |
491 | 2597 } |
2598 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
|
2599 FD_ZERO (wfds); |
491 | 2600 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
|
2601 FD_ZERO (efds); |
491 | 2602 |
2603 /* If we are looking only for the terminal, with no timeout, | |
2604 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
|
2605 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
|
2606 && FD_ISSET (0, &orfds)) |
491 | 2607 { |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2608 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
|
2609 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
|
2610 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
|
2611 goto hardway; |
491 | 2612 if (! detect_input_pending ()) |
2613 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
|
2614 FD_SET (0, rfds); |
491 | 2615 return 1; |
2616 } | |
2617 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2618 hardway: |
491 | 2619 /* Once a second, till the timer expires, check all the flagged read |
2620 * descriptors to see if any input is available. If there is some then | |
2621 * set the corresponding bit in the return copy of rfds. | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2622 */ |
491 | 2623 while (1) |
2624 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2625 register int to_check, fd; |
491 | 2626 |
2627 if (rfds) | |
2628 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2629 for (to_check = nfds, fd = 0; --to_check >= 0; fd++) |
491 | 2630 { |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2631 if (FD_ISSET (fd, &orfds)) |
491 | 2632 { |
2633 int avail = 0, status = 0; | |
2634 | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2635 if (fd == 0) |
491 | 2636 avail = detect_input_pending (); /* Special keyboard handler */ |
2637 else | |
2638 { | |
2639 #ifdef FIONREAD | |
2640 status = ioctl (fd, FIONREAD, &avail); | |
2641 #else /* no FIONREAD */ | |
2642 /* Hoping it will return -1 if nothing available | |
2643 or 0 if all 0 chars requested are read. */ | |
2644 if (proc_buffered_char[fd] >= 0) | |
2645 avail = 1; | |
2646 else | |
2647 { | |
2648 avail = read (fd, &buf, 1); | |
2649 if (avail > 0) | |
2650 proc_buffered_char[fd] = buf; | |
2651 } | |
2652 #endif /* no FIONREAD */ | |
2653 } | |
2654 if (status >= 0 && avail > 0) | |
2655 { | |
10528
e020d8d5dc2c
(sys_select): Renamed from select. Use SELECT_TYPE instead of int. Defer to
Karl Heuer <kwzh@gnu.org>
parents:
10486
diff
changeset
|
2656 FD_SET (fd, rfds); |
491 | 2657 ravail++; |
2658 } | |
2659 } | |
2660 } | |
2661 } | |
2662 if (*local_timeout == 0 || ravail != 0 || process_tick != update_tick) | |
2663 break; | |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2664 |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2665 turn_on_atimers (0); |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2666 signal (SIGALRM, select_alarm); |
491 | 2667 select_alarmed = 0; |
2668 alarm (SELECT_PAUSE); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2669 |
491 | 2670 /* Wait for a SIGALRM (or maybe a SIGTINT) */ |
2671 while (select_alarmed == 0 && *local_timeout != 0 | |
2672 && process_tick == update_tick) | |
2673 { | |
2674 /* If we are interested in terminal input, | |
2675 wait by reading the terminal. | |
2676 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
|
2677 if (FD_ISSET (0, &orfds)) |
491 | 2678 { |
2679 read_input_waiting (); | |
2680 if (detect_input_pending ()) | |
2681 select_alarmed = 1; | |
2682 } | |
2683 else | |
2684 pause (); | |
2685 } | |
2686 (*local_timeout) -= SELECT_PAUSE; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2687 |
27432
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2688 /* Reset the old alarm if there was one. */ |
b904070c3d8b
(sys_select): Turn atimers off and on instead of
Gerd Moellmann <gerd@gnu.org>
parents:
26526
diff
changeset
|
2689 turn_on_atimers (1); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
2690 |
491 | 2691 if (*local_timeout == 0) /* Stop on timer being cleared */ |
2692 break; | |
2693 } | |
2694 return ravail; | |
2695 } | |
82986
02a346f99eaf
Undo patch-23. I need a coffee.
Karoly Lorentey <lorentey@elte.hu>
parents:
82983
diff
changeset
|
2696 #endif not WINDOWSNT |
491 | 2697 |
2698 /* Read keyboard input into the standard buffer, | |
2699 waiting for at least one character. */ | |
2700 | |
13416
58e22ceabff4
[HAVE_NTGUI] (init_sys_modes, reset_sys_modes):
Geoff Voelker <voelker@cs.washington.edu>
parents:
13174
diff
changeset
|
2701 /* 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
|
2702 #ifdef HAVE_WINDOW_SYSTEM |
491 | 2703 #define BUFFER_SIZE_FACTOR 16 |
2704 #else | |
2705 #define BUFFER_SIZE_FACTOR 1 | |
2706 #endif | |
2707 | |
21514 | 2708 void |
491 | 2709 read_input_waiting () |
2710 { | |
83014
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
2711 /* XXX This needs to be updated for multi-tty support. Is there |
f5cadabb36dd
Support for opening X frames from a tty session.
Karoly Lorentey <lorentey@elte.hu>
parents:
83012
diff
changeset
|
2712 anybody who needs to emulate select these days? */ |
1014
6e25f9b75841
* sysdep.c (select): There's no need to cast the return value of
Jim Blandy <jimb@redhat.com>
parents:
766
diff
changeset
|
2713 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
|
2714 extern int quit_char; |
491 | 2715 |
2716 if (read_socket_hook) | |
2717 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2718 struct input_event buf[256]; |
51572
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2719 for (i = 0; i < 256; i++) |
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2720 EVENT_INIT (buf[i]); |
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2721 |
491 | 2722 read_alarm_should_throw = 0; |
2723 if (! setjmp (read_alarm_throw)) | |
33217
960181d7eebf
(read_input_waiting): Remove extraneous argument to
Andrew Innes <andrewi@gnu.org>
parents:
32752
diff
changeset
|
2724 nread = (*read_socket_hook) (0, buf, 256, 1); |
491 | 2725 else |
2726 nread = -1; | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2727 |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2728 /* 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
|
2729 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
|
2730 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2731 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
|
2732 /* 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
|
2733 This reduces lossage due to autorepeat on C-g. */ |
45804 | 2734 if (buf[i].kind == ASCII_KEYSTROKE_EVENT |
10946
aa943e2ea495
(read_input_waiting): Fix Lisp_Object vs. int problem.
Karl Heuer <kwzh@gnu.org>
parents:
10528
diff
changeset
|
2735 && 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
|
2736 break; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2737 } |
491 | 2738 } |
2739 else | |
2740 { | |
51572
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2741 struct input_event e; |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2742 char buf[3]; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2743 nread = read (fileno (stdin), buf, 1); |
51572
1ef0c7b51ff9
(kbd_input_ast, read_input_waiting): Don't pass uninitialized
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
51552
diff
changeset
|
2744 EVENT_INIT (e); |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2745 |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2746 /* Scan the chars for C-g and store them in kbd_buffer. */ |
45804 | 2747 e.kind = ASCII_KEYSTROKE_EVENT; |
25674
b0d0bcf1b32e
(reset_sys_modes): Change for Lisp_Object selected_frame.
Gerd Moellmann <gerd@gnu.org>
parents:
25578
diff
changeset
|
2748 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
|
2749 e.modifiers = 0; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2750 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
|
2751 { |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2752 /* 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
|
2753 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
|
2754 if (read_socket_hook == 0) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2755 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2756 /* 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
|
2757 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
|
2758 e.modifiers = meta_modifier; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2759 if (meta_key != 2) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2760 buf[i] &= ~0x80; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2761 } |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2762 |
9279
2382e2f3884e
(kbd_input_ast, read_input_waiting): Use new accessor macros instead of
Karl Heuer <kwzh@gnu.org>
parents:
9239
diff
changeset
|
2763 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
|
2764 kbd_buffer_store_event (&e); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2765 /* 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
|
2766 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
|
2767 if (buf[i] == quit_char) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
2768 break; |
4952
0c973730e476
(read_input_waiting): Don't mess with meta bit
Richard M. Stallman <rms@gnu.org>
parents:
4916
diff
changeset
|
2769 } |
491 | 2770 } |
2771 } | |
2772 | |
82988
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
2773 #if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X) |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
2774 #define select sys_select |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
2775 #endif |
f82e3a6f5ccb
A few more bugfixes and new features.
Karoly Lorentey <lorentey@elte.hu>
parents:
82987
diff
changeset
|
2776 |
491 | 2777 #endif /* not HAVE_SELECT */ |
2778 #endif /* not VMS */ | |
12988
4ccd1ffa8b33
(sys_subshell) [MSDOS]: Handle SUSPEND env var.
Richard M. Stallman <rms@gnu.org>
parents:
12547
diff
changeset
|
2779 #endif /* not MSDOS */ |
491 | 2780 |
2781 #ifdef BSD4_1 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2782 void |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2783 init_sigio (fd) |
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2784 int fd; |
491 | 2785 { |
2786 if (noninteractive) | |
2787 return; | |
2788 lmode = LINTRUP | lmode; | |
9688
31f317386c4c
Never use input_fd if using X.
Richard M. Stallman <rms@gnu.org>
parents:
9651
diff
changeset
|
2789 ioctl (fd, TIOCLSET, &lmode); |
491 | 2790 } |
2791 | |
21514 | 2792 void |
53341 | 2793 reset_sigio (fd) |
2794 int fd; | |
491 | 2795 { |
2796 if (noninteractive) | |
2797 return; | |
2798 lmode = ~LINTRUP & lmode; | |
53341 | 2799 ioctl (fd, TIOCLSET, &lmode); |
491 | 2800 } |
2801 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2802 void |
491 | 2803 request_sigio () |
2804 { | |
2805 sigrelse (SIGTINT); | |
2806 | |
2807 interrupts_deferred = 0; | |
2808 } | |
2809 | |
20367
3d1939f30ec6
(discard_tty_input, init_baud_rate,
Kenichi Handa <handa@m17n.org>
parents:
20348
diff
changeset
|
2810 void |
491 | 2811 unrequest_sigio () |
2812 { | |
2813 sighold (SIGTINT); | |
2814 | |
2815 interrupts_deferred = 1; | |
2816 } | |
2817 | |
2818 /* still inside #ifdef BSD4_1 */ | |
2819 #ifdef subprocesses | |
2820 | |
2821 int sigheld; /* Mask of held signals */ | |
2822 | |
21514 | 2823 void |
491 | 2824 sigholdx (signum) |
2825 int signum; | |
2826 { | |
2827 sigheld |= sigbit (signum); | |
2828 sighold (signum); | |
2829 } | |
2830 | |
21514 | 2831 void |
491 | 2832 sigisheld (signum) |
2833 int signum; | |
2834 { | |
2835 sigheld |= sigbit (signum); | |
2836 } | |
2837 | |
21514 | 2838 void |
491 | 2839 sigunhold (signum) |
2840 int signum; | |
2841 { | |
2842 sigheld &= ~sigbit (signum); | |
2843 sigrelse (signum); | |
2844 } | |
2845 | |
21514 | 2846 void |
491 | 2847 sigfree () /* Free all held signals */ |
2848 { | |
2849 int i; | |
2850 for (i = 0; i < NSIG; i++) | |
2851 if (sigheld & sigbit (i)) | |
2852 sigrelse (i); | |
2853 sigheld = 0; | |
2854 } | |
2855 | |
21514 | 2856 int |
491 | 2857 sigbit (i) |
2858 { | |
2859 return 1 << (i - 1); | |
2860 } | |
2861 #endif /* subprocesses */ | |
2862 #endif /* BSD4_1 */ | |
2863 | |
2864 /* POSIX signals support - DJB */ | |
2865 /* Anyone with POSIX signals should have ANSI C declarations */ | |
2866 | |
2867 #ifdef POSIX_SIGNALS | |
2868 | |
20948 | 2869 sigset_t empty_mask, full_mask; |
491 | 2870 |
2871 signal_handler_t | |
2872 sys_signal (int signal_number, signal_handler_t action) | |
2873 { | |
20948 | 2874 struct sigaction new_action, old_action; |
491 | 2875 sigemptyset (&new_action.sa_mask); |
20498
22dd2d861e36
(sys_signal): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
20456
diff
changeset
|
2876 new_action.sa_handler = action; |
46298
c6d9317e4393
(sys_signal): Test BROKEN_SA_RESTART.
Richard M. Stallman <rms@gnu.org>
parents:
45804
diff
changeset
|
2877 #if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2878 /* Emacs mostly works better with restartable system services. If this |
46298
c6d9317e4393
(sys_signal): Test BROKEN_SA_RESTART.
Richard M. Stallman <rms@gnu.org>
parents:
45804
diff
changeset
|
2879 flag exists, we probably want to turn it on here. |
c6d9317e4393
(sys_signal): Test BROKEN_SA_RESTART.
Richard M. Stallman <rms@gnu.org>
parents:
45804
diff
changeset
|
2880 However, on some systems this resets the timeout of `select' |
c6d9317e4393
(sys_signal): Test BROKEN_SA_RESTART.
Richard M. Stallman <rms@gnu.org>
parents:
45804
diff
changeset
|
2881 which means that `select' never finishes if it keeps getting signals. |
c6d9317e4393
(sys_signal): Test BROKEN_SA_RESTART.
Richard M. Stallman <rms@gnu.org>
parents:
45804
diff
changeset
|
2882 BROKEN_SA_RESTART is defined on those systems. */ |
5594
f97415a8cf41
(request_sigio, unrequest_sigio): Add new versions of
Richard M. Stallman <rms@gnu.org>
parents:
5573
diff
changeset
|
2883 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
|
2884 #else |
3292
6209d0e98e35
(sys_signal): Use 0, not NULL, to set sa_flags.
Richard M. Stallman <rms@gnu.org>
parents:
3268
diff
changeset
|
2885 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
|
2886 #endif |
709 | 2887 sigaction (signal_number, &new_action, &old_action); |
20498
22dd2d861e36
(sys_signal): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
20456
diff
changeset
|
2888 return (old_action.sa_handler); |
491 | 2889 } |
2890 | |
638 | 2891 #ifndef __GNUC__ |
2892 /* If we're compiling with GCC, we don't need this function, since it | |
2893 can be written as a macro. */ | |
2894 sigset_t | |
2895 sys_sigmask (int sig) | |
2896 { | |
2897 sigset_t mask; | |
2898 sigemptyset (&mask); | |
2899 sigaddset (&mask, sig); | |
2900 return mask; | |
2901 } | |
2902 #endif | |
2903 | |
491 | 2904 /* I'd like to have these guys return pointers to the mask storage in here, |
2905 but there'd be trouble if the code was saving multiple masks. I'll be | |
2906 safe and pass the structure. It normally won't be more than 2 bytes | |
2907 anyhow. - DJB */ | |
2908 | |
2909 sigset_t | |
2910 sys_sigblock (sigset_t new_mask) | |
2911 { | |
2912 sigset_t old_mask; | |
2913 sigprocmask (SIG_BLOCK, &new_mask, &old_mask); | |
2914 return (old_mask); | |
2915 } | |
2916 | |
2917 sigset_t | |
2918 sys_sigunblock (sigset_t new_mask) | |
2919 { | |
2920 sigset_t old_mask; | |
2921 sigprocmask (SIG_UNBLOCK, &new_mask, &old_mask); | |
2922 return (old_mask); | |
2923 } | |
2924 | |
2925 sigset_t | |
2926 sys_sigsetmask (sigset_t new_mask) | |
2927 { | |
2928 sigset_t old_mask; | |
2929 sigprocmask (SIG_SETMASK, &new_mask, &old_mask); | |
2930 return (old_mask); | |
2931 } | |
2932 | |
2933 #endif /* POSIX_SIGNALS */ | |
2934 | |
51552
d84e9160d869
Remove redundant include of unistd.h, stdlib.h. Use
Dave Love <fx@gnu.org>
parents:
51206
diff
changeset
|
2935 #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2936 static char *my_sys_siglist[NSIG]; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2937 # ifdef sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2938 # undef sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2939 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2940 # define sys_siglist my_sys_siglist |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2941 #endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2942 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2943 void |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2944 init_signals () |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2945 { |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2946 #ifdef POSIX_SIGNALS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2947 sigemptyset (&empty_mask); |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2948 sigfillset (&full_mask); |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2949 #endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2950 |
51552
d84e9160d869
Remove redundant include of unistd.h, stdlib.h. Use
Dave Love <fx@gnu.org>
parents:
51206
diff
changeset
|
2951 #if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2952 if (! initialized) |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2953 { |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2954 # ifdef SIGABRT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2955 sys_siglist[SIGABRT] = "Aborted"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2956 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2957 # ifdef SIGAIO |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2958 sys_siglist[SIGAIO] = "LAN I/O interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2959 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2960 # ifdef SIGALRM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2961 sys_siglist[SIGALRM] = "Alarm clock"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2962 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2963 # ifdef SIGBUS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2964 sys_siglist[SIGBUS] = "Bus error"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2965 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2966 # ifdef SIGCLD |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2967 sys_siglist[SIGCLD] = "Child status changed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2968 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2969 # ifdef SIGCHLD |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2970 sys_siglist[SIGCHLD] = "Child status changed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2971 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2972 # ifdef SIGCONT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2973 sys_siglist[SIGCONT] = "Continued"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2974 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2975 # ifdef SIGDANGER |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2976 sys_siglist[SIGDANGER] = "Swap space dangerously low"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2977 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2978 # ifdef SIGDGNOTIFY |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2979 sys_siglist[SIGDGNOTIFY] = "Notification message in queue"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2980 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2981 # ifdef SIGEMT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2982 sys_siglist[SIGEMT] = "Emulation trap"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2983 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2984 # ifdef SIGFPE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2985 sys_siglist[SIGFPE] = "Arithmetic exception"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2986 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2987 # ifdef SIGFREEZE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2988 sys_siglist[SIGFREEZE] = "SIGFREEZE"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2989 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2990 # ifdef SIGGRANT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2991 sys_siglist[SIGGRANT] = "Monitor mode granted"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2992 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2993 # ifdef SIGHUP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2994 sys_siglist[SIGHUP] = "Hangup"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2995 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2996 # ifdef SIGILL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2997 sys_siglist[SIGILL] = "Illegal instruction"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2998 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
2999 # ifdef SIGINT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3000 sys_siglist[SIGINT] = "Interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3001 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3002 # ifdef SIGIO |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3003 sys_siglist[SIGIO] = "I/O possible"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3004 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3005 # ifdef SIGIOINT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3006 sys_siglist[SIGIOINT] = "I/O intervention required"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3007 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3008 # ifdef SIGIOT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3009 sys_siglist[SIGIOT] = "IOT trap"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3010 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3011 # ifdef SIGKILL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3012 sys_siglist[SIGKILL] = "Killed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3013 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3014 # ifdef SIGLOST |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3015 sys_siglist[SIGLOST] = "Resource lost"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3016 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3017 # ifdef SIGLWP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3018 sys_siglist[SIGLWP] = "SIGLWP"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3019 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3020 # ifdef SIGMSG |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3021 sys_siglist[SIGMSG] = "Monitor mode data available"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3022 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3023 # ifdef SIGPHONE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3024 sys_siglist[SIGWIND] = "SIGPHONE"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3025 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3026 # ifdef SIGPIPE |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3027 sys_siglist[SIGPIPE] = "Broken pipe"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3028 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3029 # ifdef SIGPOLL |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3030 sys_siglist[SIGPOLL] = "Pollable event occurred"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3031 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3032 # ifdef SIGPROF |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3033 sys_siglist[SIGPROF] = "Profiling timer expired"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3034 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3035 # ifdef SIGPTY |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3036 sys_siglist[SIGPTY] = "PTY I/O interrupt"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3037 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3038 # ifdef SIGPWR |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3039 sys_siglist[SIGPWR] = "Power-fail restart"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3040 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3041 # ifdef SIGQUIT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3042 sys_siglist[SIGQUIT] = "Quit"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3043 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3044 # ifdef SIGRETRACT |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3045 sys_siglist[SIGRETRACT] = "Need to relinguish monitor mode"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3046 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3047 # ifdef SIGSAK |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3048 sys_siglist[SIGSAK] = "Secure attention"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3049 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3050 # ifdef SIGSEGV |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3051 sys_siglist[SIGSEGV] = "Segmentation violation"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3052 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3053 # ifdef SIGSOUND |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3054 sys_siglist[SIGSOUND] = "Sound completed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3055 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3056 # ifdef SIGSTOP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3057 sys_siglist[SIGSTOP] = "Stopped (signal)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3058 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3059 # ifdef SIGSTP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3060 sys_siglist[SIGSTP] = "Stopped (user)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3061 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3062 # ifdef SIGSYS |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3063 sys_siglist[SIGSYS] = "Bad argument to system call"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3064 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3065 # ifdef SIGTERM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3066 sys_siglist[SIGTERM] = "Terminated"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3067 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3068 # ifdef SIGTHAW |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3069 sys_siglist[SIGTHAW] = "SIGTHAW"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3070 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3071 # ifdef SIGTRAP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3072 sys_siglist[SIGTRAP] = "Trace/breakpoint trap"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3073 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3074 # ifdef SIGTSTP |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3075 sys_siglist[SIGTSTP] = "Stopped (user)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3076 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3077 # ifdef SIGTTIN |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3078 sys_siglist[SIGTTIN] = "Stopped (tty input)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3079 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3080 # ifdef SIGTTOU |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3081 sys_siglist[SIGTTOU] = "Stopped (tty output)"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3082 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3083 # ifdef SIGURG |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3084 sys_siglist[SIGURG] = "Urgent I/O condition"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3085 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3086 # ifdef SIGUSR1 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3087 sys_siglist[SIGUSR1] = "User defined signal 1"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3088 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3089 # ifdef SIGUSR2 |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3090 sys_siglist[SIGUSR2] = "User defined signal 2"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3091 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3092 # ifdef SIGVTALRM |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3093 sys_siglist[SIGVTALRM] = "Virtual timer expired"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3094 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3095 # ifdef SIGWAITING |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3096 sys_siglist[SIGWAITING] = "Process's LWPs are blocked"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3097 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3098 # ifdef SIGWINCH |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3099 sys_siglist[SIGWINCH] = "Window size changed"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3100 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3101 # ifdef SIGWIND |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3102 sys_siglist[SIGWIND] = "SIGWIND"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3103 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3104 # ifdef SIGXCPU |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3105 sys_siglist[SIGXCPU] = "CPU time limit exceeded"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3106 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3107 # ifdef SIGXFSZ |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3108 sys_siglist[SIGXFSZ] = "File size limit exceeded"; |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3109 # endif |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3110 } |
51552
d84e9160d869
Remove redundant include of unistd.h, stdlib.h. Use
Dave Love <fx@gnu.org>
parents:
51206
diff
changeset
|
3111 #endif /* !defined HAVE_STRSIGNAL && !defined HAVE_DECL_SYS_SIGLIST */ |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3112 } |
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
3113 |
2332
bc2f7dc78412
* sysdep.c (random, srandom): Don't define these if HAVE_RANDOM is
Jim Blandy <jimb@redhat.com>
parents:
2287
diff
changeset
|
3114 #ifndef HAVE_RANDOM |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3115 #ifdef random |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3116 #define HAVE_RANDOM |
8368
0c30bec316c6
(random): Use rand differently, and distinguish BSD/USG.
Richard M. Stallman <rms@gnu.org>
parents:
8358
diff
changeset
|
3117 #endif |
8358
f9d8f778f73b
(random, srandom): Obey HAVE_RAND48 flag.
Richard M. Stallman <rms@gnu.org>
parents:
8330
diff
changeset
|
3118 #endif |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3119 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3120 /* 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
|
3121 `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
|
3122 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
|
3123 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
|
3124 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3125 #ifndef RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3126 # ifdef HAVE_RANDOM |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3127 # define RAND_BITS 31 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3128 # else /* !HAVE_RANDOM */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3129 # ifdef HAVE_LRAND48 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3130 # define RAND_BITS 31 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3131 # define random lrand48 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3132 # else /* !HAVE_LRAND48 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3133 # define RAND_BITS 15 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3134 # if RAND_MAX == 32767 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3135 # define random rand |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3136 # else /* RAND_MAX != 32767 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3137 # if RAND_MAX == 2147483647 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3138 # define random() (rand () >> 16) |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3139 # else /* RAND_MAX != 2147483647 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3140 # ifdef USG |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3141 # define random rand |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3142 # else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3143 # define random() (rand () >> 16) |
16240
b448d7632094
Replaced symbol BSD with BSD_SYSTEM.
Richard M. Stallman <rms@gnu.org>
parents:
16117
diff
changeset
|
3144 # endif /* !USG */ |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3145 # endif /* RAND_MAX != 2147483647 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3146 # endif /* RAND_MAX != 32767 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3147 # endif /* !HAVE_LRAND48 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3148 # endif /* !HAVE_RANDOM */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3149 #endif /* !RAND_BITS */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3150 |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3151 void |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3152 seed_random (arg) |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3153 long arg; |
491 | 3154 { |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3155 #ifdef HAVE_RANDOM |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3156 srandom ((unsigned int)arg); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3157 #else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3158 # ifdef HAVE_LRAND48 |
8702
097fe97274e9
(srandom): Pass arg to srand48; no return value.
Karl Heuer <kwzh@gnu.org>
parents:
8699
diff
changeset
|
3159 srand48 (arg); |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3160 # else |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3161 srand ((unsigned int)arg); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3162 # endif |
8358
f9d8f778f73b
(random, srandom): Obey HAVE_RAND48 flag.
Richard M. Stallman <rms@gnu.org>
parents:
8330
diff
changeset
|
3163 #endif |
491 | 3164 } |
3165 | |
10486
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3166 /* |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3167 * 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
|
3168 * 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
|
3169 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3170 long |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3171 get_random () |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3172 { |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3173 long val = random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3174 #if VALBITS > RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3175 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3176 #if VALBITS > 2*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3177 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3178 #if VALBITS > 3*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3179 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3180 #if VALBITS > 4*RAND_BITS |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3181 val = (val << RAND_BITS) ^ random (); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3182 #endif /* need at least 5 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3183 #endif /* need at least 4 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3184 #endif /* need at least 3 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3185 #endif /* need at least 2 */ |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3186 return val & ((1L << VALBITS) - 1); |
0028c532b70b
(seed_random): Renamed from srandom.
Karl Heuer <kwzh@gnu.org>
parents:
10356
diff
changeset
|
3187 } |
491 | 3188 |
3189 #ifdef WRONG_NAME_INSQUE | |
3190 | |
3191 insque (q,p) | |
3192 caddr_t q,p; | |
3193 { | |
3194 _insque (q,p); | |
3195 } | |
3196 | |
3197 #endif | |
3198 | |
3199 #ifdef VMS | |
3200 | |
3201 #ifdef getenv | |
3202 /* If any place else asks for the TERM variable, | |
3203 allow it to be overridden with the EMACS_TERM variable | |
3204 before attempting to translate the logical name TERM. As a last | |
3205 resort, ask for VAX C's special idea of the TERM variable. */ | |
3206 #undef getenv | |
3207 char * | |
3208 sys_getenv (name) | |
3209 char *name; | |
3210 { | |
3211 register char *val; | |
3212 static char buf[256]; | |
3213 static struct dsc$descriptor_s equiv | |
3214 = {sizeof (buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf}; | |
3215 static struct dsc$descriptor_s d_name | |
3216 = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, 0}; | |
3217 short eqlen; | |
3218 | |
3219 if (!strcmp (name, "TERM")) | |
3220 { | |
3221 val = (char *) getenv ("EMACS_TERM"); | |
3222 if (val) | |
3223 return val; | |
3224 } | |
3225 | |
3226 d_name.dsc$w_length = strlen (name); | |
3227 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
|
3228 if (LIB$SYS_TRNLOG (&d_name, &eqlen, &equiv) == 1) |
491 | 3229 { |
3230 char *str = (char *) xmalloc (eqlen + 1); | |
3231 bcopy (buf, str, eqlen); | |
3232 str[eqlen] = '\0'; | |
3233 /* This is a storage leak, but a pain to fix. With luck, | |
3234 no one will ever notice. */ | |
3235 return str; | |
3236 } | |
3237 return (char *) getenv (name); | |
3238 } | |
3239 #endif /* getenv */ | |
3240 | |
3241 #ifdef abort | |
3242 /* Since VMS doesn't believe in core dumps, the only way to debug this beast is | |
3243 to force a call on the debugger from within the image. */ | |
3244 #undef abort | |
3245 sys_abort () | |
3246 { | |
53341 | 3247 reset_all_sys_modes (); |
491 | 3248 LIB$SIGNAL (SS$_DEBUG); |
3249 } | |
3250 #endif /* abort */ | |
3251 #endif /* VMS */ | |
3252 | |
3253 #ifdef VMS | |
3254 #ifdef LINK_CRTL_SHARE | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3255 #ifdef SHARABLE_LIB_BUG |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
3256 /* Variables declared noshare and initialized in sharable libraries |
491 | 3257 cannot be shared. The VMS linker incorrectly forces you to use a private |
3258 version which is uninitialized... If not for this "feature", we | |
3259 could use the C library definition of sys_nerr and sys_errlist. */ | |
3260 int sys_nerr = 35; | |
3261 char *sys_errlist[] = | |
3262 { | |
3263 "error 0", | |
3264 "not owner", | |
3265 "no such file or directory", | |
3266 "no such process", | |
3267 "interrupted system call", | |
3268 "i/o error", | |
3269 "no such device or address", | |
3270 "argument list too long", | |
3271 "exec format error", | |
3272 "bad file number", | |
3273 "no child process", | |
3274 "no more processes", | |
3275 "not enough memory", | |
3276 "permission denied", | |
3277 "bad address", | |
3278 "block device required", | |
3279 "mount devices busy", | |
3280 "file exists", | |
3281 "cross-device link", | |
3282 "no such device", | |
3283 "not a directory", | |
3284 "is a directory", | |
3285 "invalid argument", | |
3286 "file table overflow", | |
3287 "too many open files", | |
3288 "not a typewriter", | |
3289 "text file busy", | |
3290 "file too big", | |
3291 "no space left on device", | |
3292 "illegal seek", | |
3293 "read-only file system", | |
3294 "too many links", | |
3295 "broken pipe", | |
3296 "math argument", | |
3297 "result too large", | |
3298 "I/O stream empty", | |
3299 "vax/vms specific error code nontranslatable error" | |
3300 }; | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
3301 #endif /* SHARABLE_LIB_BUG */ |
491 | 3302 #endif /* LINK_CRTL_SHARE */ |
3303 #endif /* VMS */ | |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3304 |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3305 #ifndef HAVE_STRERROR |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3306 #ifndef WINDOWSNT |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3307 char * |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3308 strerror (errnum) |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3309 int errnum; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3310 { |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3311 extern char *sys_errlist[]; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3312 extern int sys_nerr; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3313 |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3314 if (errnum >= 0 && errnum < sys_nerr) |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3315 return sys_errlist[errnum]; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3316 return (char *) "Unknown error"; |
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3317 } |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
3318 #endif /* not WINDOWSNT */ |
5518
df05c1e7abe1
[! VMS]: Don't declare sys_errlist here.
Roland McGrath <roland@gnu.org>
parents:
5498
diff
changeset
|
3319 #endif /* ! HAVE_STRERROR */ |
491 | 3320 |
3321 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3322 emacs_open (path, oflag, mode) |
46475
148316527c61
(emacs_open, set_file_times): String pointer args now
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
3323 const char *path; |
491 | 3324 int oflag, mode; |
3325 { | |
3326 register int rtnval; | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3327 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3328 #ifdef BSD4_1 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3329 if (oflag & O_CREAT) |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3330 return creat (path, mode); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3331 #endif |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3332 |
491 | 3333 while ((rtnval = open (path, oflag, mode)) == -1 |
3334 && (errno == EINTR)); | |
3335 return (rtnval); | |
3336 } | |
3337 | |
21514 | 3338 int |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3339 emacs_close (fd) |
491 | 3340 int fd; |
3341 { | |
12547
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3342 int did_retry = 0; |
491 | 3343 register int rtnval; |
3344 | |
3345 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
|
3346 && (errno == EINTR)) |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3347 did_retry = 1; |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3348 |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3349 /* 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
|
3350 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
|
3351 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
|
3352 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
|
3353 return 0; |
63cdecbd7af4
(sys_close): Handle Sunos 4.1 bug in close errno value.
Karl Heuer <kwzh@gnu.org>
parents:
12326
diff
changeset
|
3354 |
491 | 3355 return rtnval; |
3356 } | |
3357 | |
3358 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3359 emacs_read (fildes, buf, nbyte) |
491 | 3360 int fildes; |
3361 char *buf; | |
3362 unsigned int nbyte; | |
3363 { | |
3364 register int rtnval; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3365 |
491 | 3366 while ((rtnval = read (fildes, buf, nbyte)) == -1 |
3367 && (errno == EINTR)); | |
3368 return (rtnval); | |
3369 } | |
3370 | |
3371 int | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3372 emacs_write (fildes, buf, nbyte) |
491 | 3373 int fildes; |
46558
d613ff01b7a8
(emacs_write): Buffer pointer now const.
Ken Raeburn <raeburn@raeburn.org>
parents:
46475
diff
changeset
|
3374 const char *buf; |
491 | 3375 unsigned int nbyte; |
3376 { | |
4772
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3377 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
|
3378 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3379 bytes_written = 0; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3380 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3381 while (nbyte > 0) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3382 { |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3383 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
|
3384 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3385 if (rtnval == -1) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3386 { |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3387 if (errno == EINTR) |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3388 continue; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3389 else |
5954
02f406110e4b
(sys_write): If any bytes were written, return how many.
Richard M. Stallman <rms@gnu.org>
parents:
5937
diff
changeset
|
3390 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
|
3391 } |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3392 |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3393 buf += rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3394 nbyte -= rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3395 bytes_written += rtnval; |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3396 } |
2c6033bfb871
(sys_write): Keep trying to write out the data until
Brian Fox <bfox@gnu.org>
parents:
4708
diff
changeset
|
3397 return (bytes_written); |
491 | 3398 } |
3399 | |
3400 #ifdef USG | |
3401 /* | |
3402 * All of the following are for USG. | |
3403 * | |
3404 * On USG systems the system calls are INTERRUPTIBLE by signals | |
3405 * that the user program has elected to catch. Thus the system call | |
3406 * must be retried in these cases. To handle this without massive | |
3407 * changes in the source code, we remap the standard system call names | |
3408 * to names for our own functions in sysdep.c that do the system call | |
3409 * with retries. Actually, for portability reasons, it is good | |
3410 * 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
|
3411 * system calls to a single occurrence in the source. Sure, this |
491 | 3412 * adds an extra level of function call overhead but it is almost |
3413 * always negligible. Fred Fish, Unisoft Systems Inc. | |
3414 */ | |
3415 | |
3416 /* | |
3417 * Warning, this function may not duplicate 4.2 action properly | |
3418 * under error conditions. | |
3419 */ | |
3420 | |
3421 #ifndef MAXPATHLEN | |
3422 /* In 4.1, param.h fails to define this. */ | |
3423 #define MAXPATHLEN 1024 | |
3424 #endif | |
3425 | |
3426 #ifndef HAVE_GETWD | |
3427 | |
3428 char * | |
3429 getwd (pathname) | |
3430 char *pathname; | |
3431 { | |
3432 char *npath, *spath; | |
3433 extern char *getcwd (); | |
3434 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3435 BLOCK_INPUT; /* getcwd uses malloc */ |
491 | 3436 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
|
3437 if (spath == 0) |
37219
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3438 { |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3439 UNBLOCK_INPUT; |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3440 return spath; |
78542938ed28
(getwd) [!HAVE_GETWD]: Unblock input before returning.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
3441 } |
491 | 3442 /* On Altos 3068, getcwd can return @hostname/dir, so discard |
3443 up to first slash. Should be harmless on other systems. */ | |
3444 while (*npath && *npath != '/') | |
3445 npath++; | |
3446 strcpy (pathname, npath); | |
3447 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
|
3448 UNBLOCK_INPUT; |
491 | 3449 return pathname; |
3450 } | |
3451 | |
3452 #endif /* HAVE_GETWD */ | |
3453 | |
3454 /* | |
3455 * Emulate rename using unlink/link. Note that this is | |
3456 * only partially correct. Also, doesn't enforce restriction | |
3457 * that files be of same type (regular->regular, dir->dir, etc). | |
3458 */ | |
3459 | |
621 | 3460 #ifndef HAVE_RENAME |
3461 | |
491 | 3462 rename (from, to) |
3842
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
3463 const char *from; |
e8bcf96f1418
* sysdep.c (rename): Make arguments const. autoconf #defines
Jim Blandy <jimb@redhat.com>
parents:
3826
diff
changeset
|
3464 const char *to; |
491 | 3465 { |
3466 if (access (from, 0) == 0) | |
3467 { | |
3468 unlink (to); | |
3469 if (link (from, to) == 0) | |
3470 if (unlink (from) == 0) | |
3471 return (0); | |
3472 } | |
3473 return (-1); | |
3474 } | |
3475 | |
621 | 3476 #endif |
3477 | |
491 | 3478 |
3479 #ifdef HPUX | |
3480 #ifndef HAVE_PERROR | |
3481 | |
3482 /* HPUX curses library references perror, but as far as we know | |
3483 it won't be called. Anyway this definition will do for now. */ | |
3484 | |
3485 perror () | |
3486 { | |
3487 } | |
3488 | |
3489 #endif /* not HAVE_PERROR */ | |
3490 #endif /* HPUX */ | |
3491 | |
3492 #ifndef HAVE_DUP2 | |
3493 | |
3494 /* | |
3495 * Emulate BSD dup2. First close newd if it already exists. | |
3496 * Then, attempt to dup oldd. If not successful, call dup2 recursively | |
3497 * until we are, then close the unsuccessful ones. | |
3498 */ | |
3499 | |
3500 dup2 (oldd, newd) | |
3501 int oldd; | |
3502 int newd; | |
3503 { | |
3504 register int fd, ret; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3505 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3506 emacs_close (newd); |
491 | 3507 |
3508 #ifdef F_DUPFD | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3509 return fcntl (oldd, F_DUPFD, newd); |
491 | 3510 #else |
3511 fd = dup (old); | |
3512 if (fd == -1) | |
3513 return -1; | |
3514 if (fd == new) | |
3515 return new; | |
3516 ret = dup2 (old,new); | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3517 emacs_close (fd); |
491 | 3518 return ret; |
3519 #endif | |
3520 } | |
3521 | |
3522 #endif /* not HAVE_DUP2 */ | |
3523 | |
3524 /* | |
3525 * Gettimeofday. Simulate as much as possible. Only accurate | |
3526 * to nearest second. Emacs doesn't use tzp so ignore it for now. | |
3527 * Only needed when subprocesses are defined. | |
3528 */ | |
3529 | |
3530 #ifdef subprocesses | |
3531 #ifndef VMS | |
3532 #ifndef HAVE_GETTIMEOFDAY | |
3533 #ifdef HAVE_TIMEVAL | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3534 |
491 | 3535 /* ARGSUSED */ |
21514 | 3536 int |
491 | 3537 gettimeofday (tp, tzp) |
3538 struct timeval *tp; | |
3539 struct timezone *tzp; | |
3540 { | |
3541 extern long time (); | |
3542 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3543 tp->tv_sec = time ((long *)0); |
491 | 3544 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
|
3545 if (tzp != 0) |
2e4882a32671
(gettimeofday): Don't store in *tzp if tzp is 0.
Richard M. Stallman <rms@gnu.org>
parents:
3157
diff
changeset
|
3546 tzp->tz_minuteswest = -1; |
21514 | 3547 return 0; |
491 | 3548 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3549 |
491 | 3550 #endif |
3551 #endif | |
3552 #endif | |
3553 #endif /* subprocess && !HAVE_GETTIMEOFDAY && HAVE_TIMEVAL && !VMS */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3554 |
491 | 3555 /* |
3556 * This function will go away as soon as all the stubs fixed. (fnf) | |
3557 */ | |
3558 | |
21514 | 3559 void |
491 | 3560 croak (badfunc) |
3561 char *badfunc; | |
3562 { | |
3563 printf ("%s not yet implemented\r\n", badfunc); | |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
3564 reset_all_sys_modes (); |
491 | 3565 exit (1); |
3566 } | |
3567 | |
3568 #endif /* USG */ | |
3569 | |
3570 /* Directory routines for systems that don't have them. */ | |
3571 | |
3572 #ifdef SYSV_SYSTEM_DIR | |
3573 | |
3574 #include <dirent.h> | |
3575 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
3576 #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
|
3577 |
491 | 3578 int |
3579 closedir (dirp) | |
3580 register DIR *dirp; /* stream from opendir */ | |
3581 { | |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3582 int rtnval; |
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3583 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3584 rtnval = emacs_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
|
3585 |
3797
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3586 /* 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
|
3587 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
|
3588 anyway? */ |
68807e370e9d
Changes for correct pgrp behavior; approach suggested by Bob
Jim Blandy <jimb@redhat.com>
parents:
3760
diff
changeset
|
3589 #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
|
3590 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
|
3591 #endif |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3592 xfree ((char *) dirp); |
5158
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3593 |
035f80625c5e
(closedir): Pass on the value from sys_closedir.
Richard M. Stallman <rms@gnu.org>
parents:
5136
diff
changeset
|
3594 return rtnval; |
491 | 3595 } |
5189
af88471e6799
(closedir): Test BROKEN_CLOSEDIR, not INTERRUPTIBLE_CLOSE.
Richard M. Stallman <rms@gnu.org>
parents:
5167
diff
changeset
|
3596 #endif /* BROKEN_CLOSEDIR or not HAVE_CLOSEDIR */ |
491 | 3597 #endif /* SYSV_SYSTEM_DIR */ |
3598 | |
3599 #ifdef NONSYSTEM_DIR_LIBRARY | |
3600 | |
3601 DIR * | |
3602 opendir (filename) | |
3603 char *filename; /* name of directory */ | |
3604 { | |
3605 register DIR *dirp; /* -> malloc'ed storage */ | |
3606 register int fd; /* file descriptor for read */ | |
3607 struct stat sbuf; /* result of fstat */ | |
3608 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3609 fd = emacs_open (filename, O_RDONLY, 0); |
491 | 3610 if (fd < 0) |
3611 return 0; | |
3612 | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3613 BLOCK_INPUT; |
491 | 3614 if (fstat (fd, &sbuf) < 0 |
3615 || (sbuf.st_mode & S_IFMT) != S_IFDIR | |
30608
4ec0adbeda9d
(opendir, GetTempDirName, run_mac_command): Use xmalloc
Gerd Moellmann <gerd@gnu.org>
parents:
29911
diff
changeset
|
3616 || (dirp = (DIR *) xmalloc (sizeof (DIR))) == 0) |
491 | 3617 { |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3618 emacs_close (fd); |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3619 UNBLOCK_INPUT; |
491 | 3620 return 0; /* bad luck today */ |
3621 } | |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
3622 UNBLOCK_INPUT; |
491 | 3623 |
3624 dirp->dd_fd = fd; | |
3625 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ | |
3626 | |
3627 return dirp; | |
3628 } | |
3629 | |
3630 void | |
3631 closedir (dirp) | |
3632 register DIR *dirp; /* stream from opendir */ | |
3633 { | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3634 emacs_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
|
3635 xfree ((char *) dirp); |
491 | 3636 } |
3637 | |
3638 | |
3639 #ifndef VMS | |
3640 #define DIRSIZ 14 | |
3641 struct olddir | |
3642 { | |
3643 ino_t od_ino; /* inode */ | |
3644 char od_name[DIRSIZ]; /* filename */ | |
3645 }; | |
3646 #endif /* not VMS */ | |
3647 | |
3648 struct direct dir_static; /* simulated directory contents */ | |
3649 | |
3650 /* ARGUSED */ | |
3651 struct direct * | |
3652 readdir (dirp) | |
3653 register DIR *dirp; /* stream from opendir */ | |
3654 { | |
3655 #ifndef VMS | |
3656 register struct olddir *dp; /* -> directory data */ | |
3657 #else /* VMS */ | |
3658 register struct dir$_name *dp; /* -> directory data */ | |
3659 register struct dir$_version *dv; /* -> version data */ | |
3660 #endif /* VMS */ | |
3661 | |
3662 for (; ;) | |
3663 { | |
3664 if (dirp->dd_loc >= dirp->dd_size) | |
3665 dirp->dd_loc = dirp->dd_size = 0; | |
3666 | |
3667 if (dirp->dd_size == 0 /* refill buffer */ | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3668 && (dirp->dd_size = emacs_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) |
491 | 3669 return 0; |
3670 | |
3671 #ifndef VMS | |
3672 dp = (struct olddir *) &dirp->dd_buf[dirp->dd_loc]; | |
3673 dirp->dd_loc += sizeof (struct olddir); | |
3674 | |
3675 if (dp->od_ino != 0) /* not deleted entry */ | |
3676 { | |
3677 dir_static.d_ino = dp->od_ino; | |
3678 strncpy (dir_static.d_name, dp->od_name, DIRSIZ); | |
3679 dir_static.d_name[DIRSIZ] = '\0'; | |
3680 dir_static.d_namlen = strlen (dir_static.d_name); | |
3681 dir_static.d_reclen = sizeof (struct direct) | |
3682 - MAXNAMLEN + 3 | |
3683 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3684 return &dir_static; /* -> simulated structure */ | |
3685 } | |
3686 #else /* VMS */ | |
3687 dp = (struct dir$_name *) dirp->dd_buf; | |
3688 if (dirp->dd_loc == 0) | |
3689 dirp->dd_loc = (dp->dir$b_namecount&1) ? dp->dir$b_namecount + 1 | |
3690 : dp->dir$b_namecount; | |
3691 dv = (struct dir$_version *)&dp->dir$t_name[dirp->dd_loc]; | |
3692 dir_static.d_ino = dv->dir$w_fid_num; | |
3693 dir_static.d_namlen = dp->dir$b_namecount; | |
3694 dir_static.d_reclen = sizeof (struct direct) | |
3695 - MAXNAMLEN + 3 | |
3696 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3697 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
3698 dir_static.d_name[dir_static.d_namlen] = '\0'; | |
3699 dirp->dd_loc = dirp->dd_size; /* only one record at a time */ | |
3700 return &dir_static; | |
3701 #endif /* VMS */ | |
3702 } | |
3703 } | |
3704 | |
3705 #ifdef VMS | |
3706 /* readdirver is just like readdir except it returns all versions of a file | |
3707 as separate entries. */ | |
3708 | |
3709 /* ARGUSED */ | |
3710 struct direct * | |
3711 readdirver (dirp) | |
3712 register DIR *dirp; /* stream from opendir */ | |
3713 { | |
3714 register struct dir$_name *dp; /* -> directory data */ | |
3715 register struct dir$_version *dv; /* -> version data */ | |
3716 | |
3717 if (dirp->dd_loc >= dirp->dd_size - sizeof (struct dir$_name)) | |
3718 dirp->dd_loc = dirp->dd_size = 0; | |
3719 | |
3720 if (dirp->dd_size == 0 /* refill buffer */ | |
3721 && (dirp->dd_size = sys_read (dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ)) <= 0) | |
3722 return 0; | |
3723 | |
3724 dp = (struct dir$_name *) dirp->dd_buf; | |
3725 if (dirp->dd_loc == 0) | |
3726 dirp->dd_loc = (dp->dir$b_namecount & 1) ? dp->dir$b_namecount + 1 | |
3727 : dp->dir$b_namecount; | |
3728 dv = (struct dir$_version *) &dp->dir$t_name[dirp->dd_loc]; | |
3729 strncpy (dir_static.d_name, dp->dir$t_name, dp->dir$b_namecount); | |
3730 sprintf (&dir_static.d_name[dp->dir$b_namecount], ";%d", dv->dir$w_version); | |
3731 dir_static.d_namlen = strlen (dir_static.d_name); | |
3732 dir_static.d_ino = dv->dir$w_fid_num; | |
3733 dir_static.d_reclen = sizeof (struct direct) - MAXNAMLEN + 3 | |
3734 + dir_static.d_namlen - dir_static.d_namlen % 4; | |
3735 dirp->dd_loc = ((char *) (++dv) - dp->dir$t_name); | |
3736 return &dir_static; | |
3737 } | |
3738 | |
3739 #endif /* VMS */ | |
3740 | |
3741 #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
|
3742 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3743 |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3744 int |
9082
2c6875700c9f
(set_file_times): Fix typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
9081
diff
changeset
|
3745 set_file_times (filename, atime, mtime) |
46475
148316527c61
(emacs_open, set_file_times): String pointer args now
Ken Raeburn <raeburn@raeburn.org>
parents:
46370
diff
changeset
|
3746 const char *filename; |
8934
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3747 EMACS_TIME atime, mtime; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3748 { |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3749 #ifdef HAVE_UTIMES |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3750 struct timeval tv[2]; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3751 tv[0] = atime; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3752 tv[1] = mtime; |
9081
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3753 return utimes (filename, tv); |
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3754 #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
|
3755 struct utimbuf utb; |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3756 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
|
3757 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
|
3758 return utime (filename, &utb); |
b85ea5d23089
(set_file_times): Don't test HAVE_UTIME.
Richard M. Stallman <rms@gnu.org>
parents:
9075
diff
changeset
|
3759 #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
|
3760 } |
e743d2957399
(set_file_times): Move this out of the USG conditional.
Karl Heuer <kwzh@gnu.org>
parents:
8881
diff
changeset
|
3761 |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3762 /* 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
|
3763 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3764 #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
|
3765 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3766 * 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
|
3767 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3768 * 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
|
3769 * 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
|
3770 * a copy. |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3771 * 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
|
3772 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3773 * 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
|
3774 * 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
|
3775 * |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3776 * 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
|
3777 * 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
|
3778 */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3779 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3780 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3781 * 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
|
3782 */ |
5682
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3783 #ifdef MKDIR_PROTOTYPE |
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3784 MKDIR_PROTOTYPE |
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3785 #else |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3786 int |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3787 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
|
3788 char *dpath; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3789 int dmode; |
5682
9204cb4fdad9
(mkdir): Use MKDIR_PROTOTYPE if defined.
Richard M. Stallman <rms@gnu.org>
parents:
5594
diff
changeset
|
3790 #endif |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3791 { |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3792 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
|
3793 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
|
3794 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3795 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
|
3796 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3797 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
|
3798 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3799 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3800 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3801 /* 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
|
3802 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
|
3803 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3804 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3805 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
|
3806 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
|
3807 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3808 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3809 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
|
3810 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
|
3811 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3812 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
|
3813 /* |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3814 * 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
|
3815 * 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
|
3816 * 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
|
3817 * 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
|
3818 */ |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3819 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
|
3820 status = umask (status | (0777 & ~dmode)); /* Set for mkdir */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3821 fd = emacs_open ("/dev/null", O_RDWR, 0); |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3822 if (fd >= 0) |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3823 { |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3824 dup2 (fd, 0); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3825 dup2 (fd, 1); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3826 dup2 (fd, 2); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3827 } |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3828 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
|
3829 _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
|
3830 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3831 default: /* Parent process */ |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3832 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
|
3833 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3834 |
53715
811d720ddd2b
(mkdir, rmdir): Also check synch_process_termsig.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
3835 if (synch_process_death != 0 || synch_process_retcode != 0 |
811d720ddd2b
(mkdir, rmdir): Also check synch_process_termsig.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
3836 || synch_process_termsig != 0) |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3837 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3838 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
|
3839 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
|
3840 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3841 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3842 return 0; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3843 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3844 #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
|
3845 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3846 #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
|
3847 int |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3848 rmdir (dpath) |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3849 char *dpath; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3850 { |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3851 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
|
3852 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
|
3853 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3854 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
|
3855 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3856 /* 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
|
3857 return -1; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3858 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3859 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3860 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
|
3861 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
|
3862 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3863 |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3864 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
|
3865 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
|
3866 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3867 case 0: /* Child process */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
3868 fd = emacs_open ("/dev/null", O_RDWR, 0); |
4643
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3869 if (fd >= 0) |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3870 { |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3871 dup2 (fd, 0); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3872 dup2 (fd, 1); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3873 dup2 (fd, 2); |
004c38daf0ae
(mkdir, rmdir): Use wait_for_termination to wait.
Richard M. Stallman <rms@gnu.org>
parents:
4640
diff
changeset
|
3874 } |
12326
b99947e6b447
(rmdir): Fix up Aug 19 1993 change that wasn't done right.
Richard M. Stallman <rms@gnu.org>
parents:
12231
diff
changeset
|
3875 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
|
3876 _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
|
3877 |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3878 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
|
3879 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
|
3880 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3881 |
53715
811d720ddd2b
(mkdir, rmdir): Also check synch_process_termsig.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
3882 if (synch_process_death != 0 || synch_process_retcode != 0 |
811d720ddd2b
(mkdir, rmdir): Also check synch_process_termsig.
Jan Djärv <jan.h.d@swipnet.se>
parents:
52401
diff
changeset
|
3883 || synch_process_termsig != 0) |
4438
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3884 { |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3885 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
|
3886 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
|
3887 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3888 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3889 return 0; |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3890 } |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3891 #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
|
3892 |
aaab60c46bff
* config.h.in: Add #undefs for HAVE_MKDIR and HAVE_RMDIR, for
Jim Blandy <jimb@redhat.com>
parents:
4430
diff
changeset
|
3893 |
491 | 3894 |
3895 /* Functions for VMS */ | |
3896 #ifdef VMS | |
579 | 3897 #include "vms-pwd.h" |
491 | 3898 #include <acldef.h> |
3899 #include <chpdef.h> | |
3900 #include <jpidef.h> | |
3901 | |
3902 /* Return as a string the VMS error string pertaining to STATUS. | |
3903 Reuses the same static buffer each time it is called. */ | |
3904 | |
3905 char * | |
3906 vmserrstr (status) | |
3907 int status; /* VMS status code */ | |
3908 { | |
3909 int bufadr[2]; | |
3910 short len; | |
3911 static char buf[257]; | |
3912 | |
3913 bufadr[0] = sizeof buf - 1; | |
3914 bufadr[1] = (int) buf; | |
3915 if (! (SYS$GETMSG (status, &len, bufadr, 0x1, 0) & 1)) | |
3916 return "untranslatable VMS error status"; | |
3917 buf[len] = '\0'; | |
3918 return buf; | |
3919 } | |
3920 | |
3921 #ifdef access | |
3922 #undef access | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3923 |
491 | 3924 /* The following is necessary because 'access' emulation by VMS C (2.0) does |
3925 * not work correctly. (It also doesn't work well in version 2.3.) | |
3926 */ | |
3927 | |
3928 #ifdef VMS4_4 | |
3929 | |
3930 #define DESCRIPTOR(name,string) struct dsc$descriptor_s name = \ | |
3931 { strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string } | |
3932 | |
3933 typedef union { | |
3934 struct { | |
3935 unsigned short s_buflen; | |
3936 unsigned short s_code; | |
3937 char *s_bufadr; | |
3938 unsigned short *s_retlenadr; | |
3939 } s; | |
3940 int end; | |
3941 } item; | |
3942 #define buflen s.s_buflen | |
3943 #define code s.s_code | |
3944 #define bufadr s.s_bufadr | |
3945 #define retlenadr s.s_retlenadr | |
3946 | |
3947 #define R_OK 4 /* test for read permission */ | |
3948 #define W_OK 2 /* test for write permission */ | |
3949 #define X_OK 1 /* test for execute (search) permission */ | |
3950 #define F_OK 0 /* test for presence of file */ | |
3951 | |
3952 int | |
3953 sys_access (path, mode) | |
3954 char *path; | |
3955 int mode; | |
3956 { | |
3957 static char *user = NULL; | |
3958 char dir_fn[512]; | |
3959 | |
3960 /* translate possible directory spec into .DIR file name, so brain-dead | |
3961 * access can treat the directory like a file. */ | |
3962 if (directory_file_name (path, dir_fn)) | |
3963 path = dir_fn; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3964 |
491 | 3965 if (mode == F_OK) |
3966 return access (path, mode); | |
3967 if (user == NULL && (user = (char *) getenv ("USER")) == NULL) | |
3968 return -1; | |
3969 { | |
3970 int stat; | |
3971 int flags; | |
3972 int acces; | |
3973 unsigned short int dummy; | |
3974 item itemlst[3]; | |
3975 static int constant = ACL$C_FILE; | |
3976 DESCRIPTOR (path_desc, path); | |
3977 DESCRIPTOR (user_desc, user); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
3978 |
491 | 3979 flags = 0; |
3980 acces = 0; | |
3981 if ((mode & X_OK) && ((stat = access (path, mode)) < 0 || mode == X_OK)) | |
3982 return stat; | |
3983 if (mode & R_OK) | |
3984 acces |= CHP$M_READ; | |
3985 if (mode & W_OK) | |
3986 acces |= CHP$M_WRITE; | |
3987 itemlst[0].buflen = sizeof (int); | |
3988 itemlst[0].code = CHP$_FLAGS; | |
3989 itemlst[0].bufadr = (char *) &flags; | |
3990 itemlst[0].retlenadr = &dummy; | |
3991 itemlst[1].buflen = sizeof (int); | |
3992 itemlst[1].code = CHP$_ACCESS; | |
3993 itemlst[1].bufadr = (char *) &acces; | |
3994 itemlst[1].retlenadr = &dummy; | |
3995 itemlst[2].end = CHP$_END; | |
3996 stat = SYS$CHECK_ACCESS (&constant, &path_desc, &user_desc, itemlst); | |
3997 return stat == SS$_NORMAL ? 0 : -1; | |
3998 } | |
3999 } | |
4000 | |
4001 #else /* not VMS4_4 */ | |
4002 | |
4003 #include <prvdef.h> | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
4004 #define ACE$M_WRITE 2 |
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
4005 #define ACE$C_KEYID 1 |
491 | 4006 |
4007 static unsigned short memid, grpid; | |
4008 static unsigned int uic; | |
4009 | |
4010 /* Called from init_sys_modes, so it happens not very often | |
4011 but at least each time Emacs is loaded. */ | |
21514 | 4012 void |
491 | 4013 sys_access_reinit () |
4014 { | |
4015 uic = 0; | |
4016 } | |
4017 | |
4018 int | |
4019 sys_access (filename, type) | |
4020 char * filename; | |
4021 int type; | |
4022 { | |
4023 struct FAB fab; | |
4024 struct XABPRO xab; | |
4025 int status, size, i, typecode, acl_controlled; | |
4026 unsigned int *aclptr, *aclend, aclbuf[60]; | |
4027 union prvdef prvmask; | |
4028 | |
4029 /* Get UIC and GRP values for protection checking. */ | |
4030 if (uic == 0) | |
4031 { | |
4032 status = LIB$GETJPI (&JPI$_UIC, 0, 0, &uic, 0, 0); | |
4033 if (! (status & 1)) | |
4034 return -1; | |
4035 memid = uic & 0xFFFF; | |
4036 grpid = uic >> 16; | |
4037 } | |
4038 | |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
4039 if (type != 2) /* not checking write access */ |
491 | 4040 return access (filename, type); |
4041 | |
4042 /* Check write protection. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4043 |
9794
64a874af5a58
[WINDOWSNT]: Add includes for NT.
Richard M. Stallman <rms@gnu.org>
parents:
9688
diff
changeset
|
4044 #define CHECKPRIV(bit) (prvmask.bit) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4045 #define WRITABLE(field) (! ((xab.xab$w_pro >> field) & XAB$M_NOWRITE)) |
491 | 4046 |
4047 /* 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
|
4048 status = SYS$SETPRV (0, 0, 0, prvmask); |
491 | 4049 if (! (status & 1)) |
4050 error ("Unable to find privileges: %s", vmserrstr (status)); | |
4051 if (CHECKPRIV (PRV$V_BYPASS)) | |
4052 return 0; /* BYPASS enabled */ | |
4053 fab = cc$rms_fab; | |
4054 fab.fab$b_fac = FAB$M_GET; | |
4055 fab.fab$l_fna = filename; | |
4056 fab.fab$b_fns = strlen (filename); | |
4057 fab.fab$l_xab = &xab; | |
4058 xab = cc$rms_xabpro; | |
4059 xab.xab$l_aclbuf = aclbuf; | |
4060 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
|
4061 status = SYS$OPEN (&fab, 0, 0); |
491 | 4062 if (! (status & 1)) |
4063 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
|
4064 SYS$CLOSE (&fab, 0, 0); |
491 | 4065 /* Check system access */ |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4066 if (CHECKPRIV (PRV$V_SYSPRV) && WRITABLE (XAB$V_SYS)) |
491 | 4067 return 0; |
4068 /* Check ACL entries, if any */ | |
4069 acl_controlled = 0; | |
4070 if (xab.xab$w_acllen > 0) | |
4071 { | |
4072 aclptr = aclbuf; | |
4073 aclend = &aclbuf[xab.xab$w_acllen / 4]; | |
4074 while (*aclptr && aclptr < aclend) | |
4075 { | |
4076 size = (*aclptr & 0xff) / 4; | |
4077 typecode = (*aclptr >> 8) & 0xff; | |
4078 if (typecode == ACE$C_KEYID) | |
4079 for (i = size - 1; i > 1; i--) | |
4080 if (aclptr[i] == uic) | |
4081 { | |
4082 acl_controlled = 1; | |
4083 if (aclptr[1] & ACE$M_WRITE) | |
4084 return 0; /* Write access through ACL */ | |
4085 } | |
4086 aclptr = &aclptr[size]; | |
4087 } | |
4088 if (acl_controlled) /* ACL specified, prohibits write access */ | |
4089 return -1; | |
4090 } | |
4091 /* No ACL entries specified, check normal protection */ | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4092 if (WRITABLE (XAB$V_WLD)) /* World writable */ |
491 | 4093 return 0; |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4094 if (WRITABLE (XAB$V_GRP) && |
491 | 4095 (unsigned short) (xab.xab$l_uic >> 16) == grpid) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4096 return 0; /* Group writable */ |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4097 if (WRITABLE (XAB$V_OWN) && |
491 | 4098 (xab.xab$l_uic & 0xFFFF) == memid) |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4099 return 0; /* Owner writable */ |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4100 |
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4101 return -1; /* Not writable */ |
491 | 4102 } |
4103 #endif /* not VMS4_4 */ | |
4104 #endif /* access */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4105 |
491 | 4106 static char vtbuf[NAM$C_MAXRSS+1]; |
4107 | |
4108 /* translate a vms file spec to a unix path */ | |
4109 char * | |
4110 sys_translate_vms (vfile) | |
4111 char * vfile; | |
4112 { | |
4113 char * p; | |
4114 char * targ; | |
4115 | |
4116 if (!vfile) | |
4117 return 0; | |
4118 | |
4119 targ = vtbuf; | |
4120 | |
4121 /* leading device or logical name is a root directory */ | |
4122 if (p = strchr (vfile, ':')) | |
4123 { | |
4124 *targ++ = '/'; | |
4125 while (vfile < p) | |
4126 *targ++ = *vfile++; | |
4127 vfile++; | |
4128 *targ++ = '/'; | |
4129 } | |
4130 p = vfile; | |
4131 if (*p == '[' || *p == '<') | |
4132 { | |
4133 while (*++vfile != *p + 2) | |
4134 switch (*vfile) | |
4135 { | |
4136 case '.': | |
4137 if (vfile[-1] == *p) | |
4138 *targ++ = '.'; | |
4139 *targ++ = '/'; | |
4140 break; | |
4141 | |
4142 case '-': | |
4143 *targ++ = '.'; | |
4144 *targ++ = '.'; | |
4145 break; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4146 |
491 | 4147 default: |
4148 *targ++ = *vfile; | |
4149 break; | |
4150 } | |
4151 vfile++; | |
4152 *targ++ = '/'; | |
4153 } | |
4154 while (*vfile) | |
4155 *targ++ = *vfile++; | |
4156 | |
4157 return vtbuf; | |
4158 } | |
4159 | |
4160 static char utbuf[NAM$C_MAXRSS+1]; | |
4161 | |
4162 /* translate a unix path to a VMS file spec */ | |
4163 char * | |
4164 sys_translate_unix (ufile) | |
4165 char * ufile; | |
4166 { | |
4167 int slash_seen = 0; | |
4168 char *p; | |
4169 char * targ; | |
4170 | |
4171 if (!ufile) | |
4172 return 0; | |
4173 | |
4174 targ = utbuf; | |
4175 | |
4176 if (*ufile == '/') | |
4177 { | |
4178 ufile++; | |
4179 } | |
4180 | |
4181 while (*ufile) | |
4182 { | |
4183 switch (*ufile) | |
4184 { | |
4185 case '/': | |
4186 if (slash_seen) | |
4187 if (index (&ufile[1], '/')) | |
4188 *targ++ = '.'; | |
4189 else | |
4190 *targ++ = ']'; | |
4191 else | |
4192 { | |
4193 *targ++ = ':'; | |
4194 if (index (&ufile[1], '/')) | |
4195 *targ++ = '['; | |
4196 slash_seen = 1; | |
4197 } | |
4198 break; | |
4199 | |
4200 case '.': | |
4201 if (strncmp (ufile, "./", 2) == 0) | |
4202 { | |
4203 if (!slash_seen) | |
4204 { | |
4205 *targ++ = '['; | |
4206 slash_seen = 1; | |
4207 } | |
4208 ufile++; /* skip the dot */ | |
4209 if (index (&ufile[1], '/')) | |
4210 *targ++ = '.'; | |
4211 else | |
4212 *targ++ = ']'; | |
4213 } | |
4214 else if (strncmp (ufile, "../", 3) == 0) | |
4215 { | |
4216 if (!slash_seen) | |
4217 { | |
4218 *targ++ = '['; | |
4219 slash_seen = 1; | |
4220 } | |
4221 *targ++ = '-'; | |
4222 ufile += 2; /* skip the dots */ | |
4223 if (index (&ufile[1], '/')) | |
4224 *targ++ = '.'; | |
4225 else | |
4226 *targ++ = ']'; | |
4227 } | |
4228 else | |
4229 *targ++ = *ufile; | |
4230 break; | |
4231 | |
4232 default: | |
4233 *targ++ = *ufile; | |
4234 break; | |
4235 } | |
4236 ufile++; | |
4237 } | |
4238 *targ = '\0'; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4239 |
491 | 4240 return utbuf; |
4241 } | |
4242 | |
4243 char * | |
4244 getwd (pathname) | |
4245 char *pathname; | |
4246 { | |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4247 char *ptr, *val; |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4248 extern char *getcwd (); |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4249 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4250 #define MAXPATHLEN 1024 |
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4251 |
2439
b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents:
2332
diff
changeset
|
4252 ptr = xmalloc (MAXPATHLEN); |
5136
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4253 val = getcwd (ptr, MAXPATHLEN); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4254 if (val == 0) |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4255 { |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4256 xfree (ptr); |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4257 return val; |
500f269bf0a8
(getwd): If getcwd returns 0, we return 0.
Richard M. Stallman <rms@gnu.org>
parents:
4958
diff
changeset
|
4258 } |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4259 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
|
4260 xfree (ptr); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4261 |
2264
87934d212841
Some VMS changes from Richard Levitte <levitte@e.kth.se>:
Jim Blandy <jimb@redhat.com>
parents:
2121
diff
changeset
|
4262 return pathname; |
491 | 4263 } |
4264 | |
21514 | 4265 int |
491 | 4266 getppid () |
4267 { | |
4268 long item_code = JPI$_OWNER; | |
4269 unsigned long parent_id; | |
4270 int status; | |
4271 | |
4272 if (((status = LIB$GETJPI (&item_code, 0, 0, &parent_id)) & 1) == 0) | |
4273 { | |
4274 errno = EVMSERR; | |
4275 vaxc$errno = status; | |
4276 return -1; | |
4277 } | |
4278 return parent_id; | |
4279 } | |
4280 | |
4281 #undef getuid | |
4282 unsigned | |
4283 sys_getuid () | |
4284 { | |
4285 return (getgid () << 16) | getuid (); | |
4286 } | |
4287 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
4288 #undef read |
491 | 4289 int |
4290 sys_read (fildes, buf, nbyte) | |
4291 int fildes; | |
4292 char *buf; | |
4293 unsigned int nbyte; | |
4294 { | |
4295 return read (fildes, buf, (nbyte < MAXIOSIZE ? nbyte : MAXIOSIZE)); | |
4296 } | |
4297 | |
4298 #if 0 | |
4299 int | |
4300 sys_write (fildes, buf, nbyte) | |
4301 int fildes; | |
4302 char *buf; | |
4303 unsigned int nbyte; | |
4304 { | |
4305 register int nwrote, rtnval = 0; | |
4306 | |
4307 while (nbyte > MAXIOSIZE && (nwrote = write (fildes, buf, MAXIOSIZE)) > 0) { | |
4308 nbyte -= nwrote; | |
4309 buf += nwrote; | |
4310 rtnval += nwrote; | |
4311 } | |
4312 if (nwrote < 0) | |
4313 return rtnval ? rtnval : -1; | |
4314 if ((nwrote = write (fildes, buf, nbyte)) < 0) | |
4315 return rtnval ? rtnval : -1; | |
4316 return (rtnval + nwrote); | |
4317 } | |
4318 #endif /* 0 */ | |
4319 | |
4320 /* | |
4321 * VAX/VMS VAX C RTL really loses. It insists that records | |
4322 * end with a newline (carriage return) character, and if they | |
4323 * don't it adds one (nice of it isn't it!) | |
4324 * | |
4325 * Thus we do this stupidity below. | |
4326 */ | |
4327 | |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
4328 #undef write |
491 | 4329 int |
4330 sys_write (fildes, buf, nbytes) | |
4331 int fildes; | |
4332 char *buf; | |
4333 unsigned int nbytes; | |
4334 { | |
4335 register char *p; | |
4336 register char *e; | |
525 | 4337 int sum = 0; |
4338 struct stat st; | |
4339 | |
4340 fstat (fildes, &st); | |
491 | 4341 p = buf; |
4342 while (nbytes > 0) | |
4343 { | |
525 | 4344 int len, retval; |
4345 | |
4346 /* Handle fixed-length files with carriage control. */ | |
4347 if (st.st_fab_rfm == FAB$C_FIX | |
4348 && ((st.st_fab_rat & (FAB$M_FTN | FAB$M_CR)) != 0)) | |
4349 { | |
4350 len = st.st_fab_mrs; | |
4351 retval = write (fildes, p, min (len, nbytes)); | |
4352 if (retval != len) | |
4353 return -1; | |
4354 retval++; /* This skips the implied carriage control */ | |
4355 } | |
4356 else | |
4357 { | |
4358 e = p + min (MAXIOSIZE, nbytes) - 1; | |
4359 while (*e != '\n' && e > p) e--; | |
4360 if (p == e) /* Ok.. so here we add a newline... sigh. */ | |
4361 e = p + min (MAXIOSIZE, nbytes) - 1; | |
4362 len = e + 1 - p; | |
4363 retval = write (fildes, p, len); | |
4364 if (retval != len) | |
4365 return -1; | |
4366 } | |
4367 p += retval; | |
4368 sum += retval; | |
491 | 4369 nbytes -= retval; |
4370 } | |
4371 return sum; | |
4372 } | |
4373 | |
4374 /* Create file NEW copying its attributes from file OLD. If | |
4375 OLD is 0 or does not exist, create based on the value of | |
4376 vms_stmlf_recfm. */ | |
4377 | |
4378 /* Protection value the file should ultimately have. | |
4379 Set by create_copy_attrs, and use by rename_sansversions. */ | |
4380 static unsigned short int fab_final_pro; | |
4381 | |
4382 int | |
4383 creat_copy_attrs (old, new) | |
4384 char *old, *new; | |
4385 { | |
4386 struct FAB fab = cc$rms_fab; | |
4387 struct XABPRO xabpro; | |
4388 char aclbuf[256]; /* Choice of size is arbitrary. See below. */ | |
4389 extern int vms_stmlf_recfm; | |
4390 | |
4391 if (old) | |
4392 { | |
4393 fab.fab$b_fac = FAB$M_GET; | |
4394 fab.fab$l_fna = old; | |
4395 fab.fab$b_fns = strlen (old); | |
4396 fab.fab$l_xab = (char *) &xabpro; | |
4397 xabpro = cc$rms_xabpro; | |
4398 xabpro.xab$l_aclbuf = aclbuf; | |
4399 xabpro.xab$w_aclsiz = sizeof aclbuf; | |
4400 /* 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
|
4401 if (SYS$OPEN (&fab, 0, 0) & 1) |
491 | 4402 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4403 SYS$CLOSE (&fab, 0, 0); |
491 | 4404 fab.fab$l_alq = 0; /* zero the allocation quantity */ |
4405 if (xabpro.xab$w_acllen > 0) | |
4406 { | |
4407 if (xabpro.xab$w_acllen > sizeof aclbuf) | |
4408 /* If the acl buffer was too short, redo open with longer one. | |
4409 Wouldn't need to do this if there were some system imposed | |
4410 limit on the size of an ACL, but I can't find any such. */ | |
4411 { | |
4412 xabpro.xab$l_aclbuf = (char *) alloca (xabpro.xab$w_acllen); | |
4413 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
|
4414 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
|
4415 SYS$CLOSE (&fab, 0, 0); |
491 | 4416 else |
4417 old = 0; | |
4418 } | |
4419 } | |
4420 else | |
4421 xabpro.xab$l_aclbuf = 0; | |
4422 } | |
4423 else | |
4424 old = 0; | |
4425 } | |
4426 fab.fab$l_fna = new; | |
4427 fab.fab$b_fns = strlen (new); | |
4428 if (!old) | |
4429 { | |
4430 fab.fab$l_xab = 0; | |
4431 fab.fab$b_rfm = vms_stmlf_recfm ? FAB$C_STMLF : FAB$C_VAR; | |
4432 fab.fab$b_rat = FAB$M_CR; | |
4433 } | |
4434 | |
4435 /* Set the file protections such that we will be able to manipulate | |
4436 this file. Once we are done writing and renaming it, we will set | |
4437 the protections back. */ | |
4438 if (old) | |
4439 fab_final_pro = xabpro.xab$w_pro; | |
4440 else | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4441 SYS$SETDFPROT (0, &fab_final_pro); |
491 | 4442 xabpro.xab$w_pro &= 0xff0f; /* set O:rewd for now. This is set back later. */ |
4443 | |
4444 /* Create the new file with either default attrs or attrs copied | |
4445 from old file. */ | |
4446 if (!(SYS$CREATE (&fab, 0, 0) & 1)) | |
4447 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
|
4448 SYS$CLOSE (&fab, 0, 0); |
491 | 4449 /* As this is a "replacement" for creat, return a file descriptor |
4450 opened for writing. */ | |
4451 return open (new, O_WRONLY); | |
4452 } | |
4453 | |
4454 #ifdef creat | |
4455 #undef creat | |
4456 #include <varargs.h> | |
4457 #ifdef __GNUC__ | |
4458 #ifndef va_count | |
4459 #define va_count(X) ((X) = *(((int *) &(va_alist)) - 1)) | |
4460 #endif | |
4461 #endif | |
4462 | |
21514 | 4463 int |
491 | 4464 sys_creat (va_alist) |
4465 va_dcl | |
4466 { | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4467 va_list list_incrementer; |
491 | 4468 char *name; |
4469 int mode; | |
4470 int rfd; /* related file descriptor */ | |
4471 int fd; /* Our new file descriptor */ | |
4472 int count; | |
4473 struct stat st_buf; | |
4474 char rfm[12]; | |
4475 char rat[15]; | |
4476 char mrs[13]; | |
4477 char fsz[13]; | |
4478 extern int vms_stmlf_recfm; | |
4479 | |
4480 va_count (count); | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4481 va_start (list_incrementer); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4482 name = va_arg (list_incrementer, char *); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4483 mode = va_arg (list_incrementer, int); |
491 | 4484 if (count > 2) |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4485 rfd = va_arg (list_incrementer, int); |
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3559
diff
changeset
|
4486 va_end (list_incrementer); |
491 | 4487 if (count > 2) |
4488 { | |
4489 /* Use information from the related file descriptor to set record | |
4490 format of the newly created file. */ | |
4491 fstat (rfd, &st_buf); | |
4492 switch (st_buf.st_fab_rfm) | |
4493 { | |
4494 case FAB$C_FIX: | |
4495 strcpy (rfm, "rfm = fix"); | |
4496 sprintf (mrs, "mrs = %d", st_buf.st_fab_mrs); | |
4497 strcpy (rat, "rat = "); | |
4498 if (st_buf.st_fab_rat & FAB$M_CR) | |
4499 strcat (rat, "cr"); | |
4500 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4501 strcat (rat, "ftn"); | |
4502 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4503 strcat (rat, "prn"); | |
4504 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4505 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4506 strcat (rat, ", blk"); | |
4507 else | |
4508 strcat (rat, "blk"); | |
4509 return creat (name, 0, rfm, rat, mrs); | |
4510 | |
4511 case FAB$C_VFC: | |
4512 strcpy (rfm, "rfm = vfc"); | |
4513 sprintf (fsz, "fsz = %d", st_buf.st_fab_fsz); | |
4514 strcpy (rat, "rat = "); | |
4515 if (st_buf.st_fab_rat & FAB$M_CR) | |
4516 strcat (rat, "cr"); | |
4517 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4518 strcat (rat, "ftn"); | |
4519 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4520 strcat (rat, "prn"); | |
4521 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4522 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4523 strcat (rat, ", blk"); | |
4524 else | |
4525 strcat (rat, "blk"); | |
4526 return creat (name, 0, rfm, rat, fsz); | |
4527 | |
4528 case FAB$C_STM: | |
4529 strcpy (rfm, "rfm = stm"); | |
4530 break; | |
4531 | |
4532 case FAB$C_STMCR: | |
4533 strcpy (rfm, "rfm = stmcr"); | |
4534 break; | |
4535 | |
4536 case FAB$C_STMLF: | |
4537 strcpy (rfm, "rfm = stmlf"); | |
4538 break; | |
4539 | |
4540 case FAB$C_UDF: | |
4541 strcpy (rfm, "rfm = udf"); | |
4542 break; | |
4543 | |
4544 case FAB$C_VAR: | |
4545 strcpy (rfm, "rfm = var"); | |
4546 break; | |
4547 } | |
4548 strcpy (rat, "rat = "); | |
4549 if (st_buf.st_fab_rat & FAB$M_CR) | |
4550 strcat (rat, "cr"); | |
4551 else if (st_buf.st_fab_rat & FAB$M_FTN) | |
4552 strcat (rat, "ftn"); | |
4553 else if (st_buf.st_fab_rat & FAB$M_PRN) | |
4554 strcat (rat, "prn"); | |
4555 if (st_buf.st_fab_rat & FAB$M_BLK) | |
4556 if (st_buf.st_fab_rat & (FAB$M_CR|FAB$M_FTN|FAB$M_PRN)) | |
4557 strcat (rat, ", blk"); | |
4558 else | |
4559 strcat (rat, "blk"); | |
4560 } | |
4561 else | |
4562 { | |
4563 strcpy (rfm, vms_stmlf_recfm ? "rfm = stmlf" : "rfm=var"); | |
4564 strcpy (rat, "rat=cr"); | |
4565 } | |
4566 /* Until the VAX C RTL fixes the many bugs with modes, always use | |
4567 mode 0 to get the user's default protection. */ | |
4568 fd = creat (name, 0, rfm, rat); | |
4569 if (fd < 0 && errno == EEXIST) | |
4570 { | |
4571 if (unlink (name) < 0) | |
4572 report_file_error ("delete", build_string (name)); | |
4573 fd = creat (name, 0, rfm, rat); | |
4574 } | |
4575 return fd; | |
4576 } | |
4577 #endif /* creat */ | |
4578 | |
4579 /* fwrite to stdout is S L O W. Speed it up by using fputc...*/ | |
21514 | 4580 int |
491 | 4581 sys_fwrite (ptr, size, num, fp) |
4582 register char * ptr; | |
4583 FILE * fp; | |
4584 { | |
4585 register int tot = num * size; | |
4586 | |
4587 while (tot--) | |
4588 fputc (*ptr++, fp); | |
21514 | 4589 return num; |
491 | 4590 } |
4591 | |
4592 /* | |
4593 * The VMS C library routine creat actually creates a new version of an | |
4594 * existing file rather than truncating the old version. There are times | |
4595 * when this is not the desired behavior, for instance, when writing an | |
4596 * auto save file (you only want one version), or when you don't have | |
4597 * write permission in the directory containing the file (but the file | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4598 * itself is writable). Hence this routine, which is equivalent to |
491 | 4599 * "close (creat (fn, 0));" on Unix if fn already exists. |
4600 */ | |
4601 int | |
4602 vms_truncate (fn) | |
4603 char *fn; | |
4604 { | |
4605 struct FAB xfab = cc$rms_fab; | |
4606 struct RAB xrab = cc$rms_rab; | |
4607 int status; | |
4608 | |
4609 xfab.fab$l_fop = FAB$M_TEF; /* free allocated but unused blocks on close */ | |
4610 xfab.fab$b_fac = FAB$M_TRN | FAB$M_GET; /* allow truncate and get access */ | |
4611 xfab.fab$b_shr = FAB$M_NIL; /* allow no sharing - file must be locked */ | |
4612 xfab.fab$l_fna = fn; | |
4613 xfab.fab$b_fns = strlen (fn); | |
4614 xfab.fab$l_dna = ";0"; /* default to latest version of the file */ | |
4615 xfab.fab$b_dns = 2; | |
4616 xrab.rab$l_fab = &xfab; | |
4617 | |
4618 /* This gibberish opens the file, positions to the first record, and | |
4619 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
|
4620 if ((SYS$OPEN (&xfab) & 01) == 01) |
491 | 4621 { |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4622 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
|
4623 (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
|
4624 (SYS$TRUNCATE (&xrab) & 01) == 01) |
491 | 4625 status = 0; |
4626 else | |
4627 status = -1; | |
4628 } | |
4629 else | |
4630 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
|
4631 SYS$CLOSE (&xfab); |
491 | 4632 return status; |
4633 } | |
4634 | |
4635 /* Define this symbol to actually read SYSUAF.DAT. This requires either | |
4636 SYSPRV or a readable SYSUAF.DAT. */ | |
4637 | |
4638 #ifdef READ_SYSUAF | |
4639 /* | |
4640 * getuaf.c | |
4641 * | |
4642 * Routine to read the VMS User Authorization File and return | |
4643 * a specific user's record. | |
4644 */ | |
4645 | |
4646 static struct UAF retuaf; | |
4647 | |
4648 struct UAF * | |
4649 get_uaf_name (uname) | |
4650 char * uname; | |
4651 { | |
4652 register status; | |
4653 struct FAB uaf_fab; | |
4654 struct RAB uaf_rab; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4655 |
491 | 4656 uaf_fab = cc$rms_fab; |
4657 uaf_rab = cc$rms_rab; | |
4658 /* initialize fab fields */ | |
4659 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
4660 uaf_fab.fab$b_fns = 21; | |
4661 uaf_fab.fab$b_fac = FAB$M_GET; | |
4662 uaf_fab.fab$b_org = FAB$C_IDX; | |
4663 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
4664 /* initialize rab fields */ | |
4665 uaf_rab.rab$l_fab = &uaf_fab; | |
4666 /* 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
|
4667 status = SYS$OPEN (&uaf_fab); |
491 | 4668 if (!(status&1)) |
4669 { | |
4670 errno = EVMSERR; | |
4671 vaxc$errno = status; | |
4672 return 0; | |
4673 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4674 status = SYS$CONNECT (&uaf_rab); |
491 | 4675 if (!(status&1)) |
4676 { | |
4677 errno = EVMSERR; | |
4678 vaxc$errno = status; | |
4679 return 0; | |
4680 } | |
4681 /* read the requested record - index is in uname */ | |
4682 uaf_rab.rab$l_kbf = uname; | |
4683 uaf_rab.rab$b_ksz = strlen (uname); | |
4684 uaf_rab.rab$b_rac = RAB$C_KEY; | |
4685 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
4686 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
|
4687 status = SYS$GET (&uaf_rab); |
491 | 4688 if (!(status&1)) |
4689 { | |
4690 errno = EVMSERR; | |
4691 vaxc$errno = status; | |
4692 return 0; | |
4693 } | |
4694 /* 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
|
4695 status = SYS$DISCONNECT (&uaf_rab); |
491 | 4696 if (!(status&1)) |
4697 { | |
4698 errno = EVMSERR; | |
4699 vaxc$errno = status; | |
4700 return 0; | |
4701 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4702 status = SYS$CLOSE (&uaf_fab); |
491 | 4703 if (!(status&1)) |
4704 { | |
4705 errno = EVMSERR; | |
4706 vaxc$errno = status; | |
4707 return 0; | |
4708 } | |
4709 return &retuaf; | |
4710 } | |
4711 | |
4712 struct UAF * | |
4713 get_uaf_uic (uic) | |
4714 unsigned long uic; | |
4715 { | |
4716 register status; | |
4717 struct FAB uaf_fab; | |
4718 struct RAB uaf_rab; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
4719 |
491 | 4720 uaf_fab = cc$rms_fab; |
4721 uaf_rab = cc$rms_rab; | |
4722 /* initialize fab fields */ | |
4723 uaf_fab.fab$l_fna = "SYS$SYSTEM:SYSUAF.DAT"; | |
4724 uaf_fab.fab$b_fns = 21; | |
4725 uaf_fab.fab$b_fac = FAB$M_GET; | |
4726 uaf_fab.fab$b_org = FAB$C_IDX; | |
4727 uaf_fab.fab$b_shr = FAB$M_GET|FAB$M_PUT|FAB$M_UPD|FAB$M_DEL; | |
4728 /* initialize rab fields */ | |
4729 uaf_rab.rab$l_fab = &uaf_fab; | |
4730 /* 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
|
4731 status = SYS$OPEN (&uaf_fab); |
491 | 4732 if (!(status&1)) |
4733 { | |
4734 errno = EVMSERR; | |
4735 vaxc$errno = status; | |
4736 return 0; | |
4737 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4738 status = SYS$CONNECT (&uaf_rab); |
491 | 4739 if (!(status&1)) |
4740 { | |
4741 errno = EVMSERR; | |
4742 vaxc$errno = status; | |
4743 return 0; | |
4744 } | |
4745 /* read the requested record - index is in uic */ | |
4746 uaf_rab.rab$b_krf = 1; /* 1st alternate key */ | |
4747 uaf_rab.rab$l_kbf = (char *) &uic; | |
4748 uaf_rab.rab$b_ksz = sizeof uic; | |
4749 uaf_rab.rab$b_rac = RAB$C_KEY; | |
4750 uaf_rab.rab$l_ubf = (char *)&retuaf; | |
4751 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
|
4752 status = SYS$GET (&uaf_rab); |
491 | 4753 if (!(status&1)) |
4754 { | |
4755 errno = EVMSERR; | |
4756 vaxc$errno = status; | |
4757 return 0; | |
4758 } | |
4759 /* 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
|
4760 status = SYS$DISCONNECT (&uaf_rab); |
491 | 4761 if (!(status&1)) |
4762 { | |
4763 errno = EVMSERR; | |
4764 vaxc$errno = status; | |
4765 return 0; | |
4766 } | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
4767 status = SYS$CLOSE (&uaf_fab); |
491 | 4768 if (!(status&1)) |
4769 { | |
4770 errno = EVMSERR; | |
4771 vaxc$errno = status; | |
4772 return 0; | |
4773 } | |
4774 return &retuaf; | |
4775 } | |
4776 | |
4777 static struct passwd retpw; | |
4778 | |
4779 struct passwd * | |
4780 cnv_uaf_pw (up) | |
4781 struct UAF * up; | |
4782 { | |
4783 char * ptr; | |
4784 | |
4785 /* copy these out first because if the username is 32 chars, the next | |
4786 section will overwrite the first byte of the UIC */ | |
4787 retpw.pw_uid = up->uaf$w_mem; | |
4788 retpw.pw_gid = up->uaf$w_grp; | |
4789 | |
13943
f3c41057bf41
(WRITABLE): Renamed from WRITEABLE.
Karl Heuer <kwzh@gnu.org>
parents:
13416
diff
changeset
|
4790 /* I suppose this is not the best style, to possibly overwrite one |
491 | 4791 byte beyond the end of the field, but what the heck... */ |
4792 ptr = &up->uaf$t_username[UAF$S_USERNAME]; | |
4793 while (ptr[-1] == ' ') | |
4794 ptr--; | |
4795 *ptr = '\0'; | |
4796 strcpy (retpw.pw_name, up->uaf$t_username); | |
4797 | |
4798 /* the rest of these are counted ascii strings */ | |
4799 strncpy (retpw.pw_gecos, &up->uaf$t_owner[1], up->uaf$t_owner[0]); | |
4800 retpw.pw_gecos[up->uaf$t_owner[0]] = '\0'; | |
4801 strncpy (retpw.pw_dir, &up->uaf$t_defdev[1], up->uaf$t_defdev[0]); | |
4802 retpw.pw_dir[up->uaf$t_defdev[0]] = '\0'; | |
4803 strncat (retpw.pw_dir, &up->uaf$t_defdir[1], up->uaf$t_defdir[0]); | |
4804 retpw.pw_dir[up->uaf$t_defdev[0] + up->uaf$t_defdir[0]] = '\0'; | |
4805 strncpy (retpw.pw_shell, &up->uaf$t_defcli[1], up->uaf$t_defcli[0]); | |
4806 retpw.pw_shell[up->uaf$t_defcli[0]] = '\0'; | |
4807 | |
4808 return &retpw; | |
4809 } | |
4810 #else /* not READ_SYSUAF */ | |
4811 static struct passwd retpw; | |
4812 #endif /* not READ_SYSUAF */ | |
4813 | |
4814 struct passwd * | |
4815 getpwnam (name) | |
4816 char * name; | |
4817 { | |
4818 #ifdef READ_SYSUAF | |
4819 struct UAF *up; | |
4820 #else | |
4821 char * user; | |
4822 char * dir; | |
4823 unsigned char * full; | |
4824 #endif /* READ_SYSUAF */ | |
4825 char *ptr = name; | |
4826 | |
4827 while (*ptr) | |
4828 { | |
4829 if ('a' <= *ptr && *ptr <= 'z') | |
4830 *ptr -= 040; | |
4831 ptr++; | |
4832 } | |
4833 #ifdef READ_SYSUAF | |
4834 if (!(up = get_uaf_name (name))) | |
4835 return 0; | |
4836 return cnv_uaf_pw (up); | |
4837 #else | |
4838 if (strcmp (name, getenv ("USER")) == 0) | |
4839 { | |
4840 retpw.pw_uid = getuid (); | |
4841 retpw.pw_gid = getgid (); | |
4842 strcpy (retpw.pw_name, name); | |
4843 if (full = egetenv ("FULLNAME")) | |
4844 strcpy (retpw.pw_gecos, full); | |
4845 else | |
4846 *retpw.pw_gecos = '\0'; | |
4847 strcpy (retpw.pw_dir, egetenv ("HOME")); | |
4848 *retpw.pw_shell = '\0'; | |
4849 return &retpw; | |
4850 } | |
4851 else | |
4852 return 0; | |
4853 #endif /* not READ_SYSUAF */ | |
4854 } | |
4855 | |
4856 struct passwd * | |
4857 getpwuid (uid) | |
4858 unsigned long uid; | |
4859 { | |
4860 #ifdef READ_SYSUAF | |
4861 struct UAF * up; | |
4862 | |
4863 if (!(up = get_uaf_uic (uid))) | |
4864 return 0; | |
4865 return cnv_uaf_pw (up); | |
4866 #else | |
4867 if (uid == sys_getuid ()) | |
4868 return getpwnam (egetenv ("USER")); | |
4869 else | |
4870 return 0; | |
4871 #endif /* not READ_SYSUAF */ | |
4872 } | |
4873 | |
4874 /* return total address space available to the current process. This is | |
4875 the sum of the current p0 size, p1 size and free page table entries | |
4876 available. */ | |
21514 | 4877 int |
491 | 4878 vlimit () |
4879 { | |
4880 int item_code; | |
4881 unsigned long free_pages; | |
4882 unsigned long frep0va; | |
4883 unsigned long frep1va; | |
4884 register status; | |
4885 | |
4886 item_code = JPI$_FREPTECNT; | |
4887 if (((status = LIB$GETJPI (&item_code, 0, 0, &free_pages)) & 1) == 0) | |
4888 { | |
4889 errno = EVMSERR; | |
4890 vaxc$errno = status; | |
4891 return -1; | |
4892 } | |
4893 free_pages *= 512; | |
4894 | |
4895 item_code = JPI$_FREP0VA; | |
4896 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep0va)) & 1) == 0) | |
4897 { | |
4898 errno = EVMSERR; | |
4899 vaxc$errno = status; | |
4900 return -1; | |
4901 } | |
4902 item_code = JPI$_FREP1VA; | |
4903 if (((status = LIB$GETJPI (&item_code, 0, 0, &frep1va)) & 1) == 0) | |
4904 { | |
4905 errno = EVMSERR; | |
4906 vaxc$errno = status; | |
4907 return -1; | |
4908 } | |
4909 | |
4910 return free_pages + frep0va + (0x7fffffff - frep1va); | |
4911 } | |
4912 | |
21514 | 4913 int |
491 | 4914 define_logical_name (varname, string) |
4915 char *varname; | |
4916 char *string; | |
4917 { | |
4918 struct dsc$descriptor_s strdsc = | |
4919 {strlen (string), DSC$K_DTYPE_T, DSC$K_CLASS_S, string}; | |
4920 struct dsc$descriptor_s envdsc = | |
4921 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
4922 struct dsc$descriptor_s lnmdsc = | |
4923 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
4924 | |
4925 return LIB$SET_LOGICAL (&envdsc, &strdsc, &lnmdsc, 0, 0); | |
4926 } | |
4927 | |
21514 | 4928 int |
491 | 4929 delete_logical_name (varname) |
4930 char *varname; | |
4931 { | |
4932 struct dsc$descriptor_s envdsc = | |
4933 {strlen (varname), DSC$K_DTYPE_T, DSC$K_CLASS_S, varname}; | |
4934 struct dsc$descriptor_s lnmdsc = | |
4935 {7, DSC$K_DTYPE_T, DSC$K_CLASS_S, "LNM$JOB"}; | |
4936 | |
4937 return LIB$DELETE_LOGICAL (&envdsc, &lnmdsc); | |
4938 } | |
4939 | |
21514 | 4940 int |
491 | 4941 ulimit () |
21514 | 4942 { |
4943 return 0; | |
4944 } | |
4945 | |
4946 int | |
491 | 4947 setpgrp () |
21514 | 4948 { |
4949 return 0; | |
4950 } | |
4951 | |
4952 int | |
491 | 4953 execvp () |
4954 { | |
4955 error ("execvp system call not implemented"); | |
21514 | 4956 return -1; |
491 | 4957 } |
4958 | |
4959 int | |
4960 rename (from, to) | |
4961 char *from, *to; | |
4962 { | |
4963 int status; | |
4964 struct FAB from_fab = cc$rms_fab, to_fab = cc$rms_fab; | |
4965 struct NAM from_nam = cc$rms_nam, to_nam = cc$rms_nam; | |
4966 char from_esn[NAM$C_MAXRSS]; | |
4967 char to_esn[NAM$C_MAXRSS]; | |
4968 | |
4969 from_fab.fab$l_fna = from; | |
4970 from_fab.fab$b_fns = strlen (from); | |
4971 from_fab.fab$l_nam = &from_nam; | |
4972 from_fab.fab$l_fop = FAB$M_NAM; | |
4973 | |
4974 from_nam.nam$l_esa = from_esn; | |
4975 from_nam.nam$b_ess = sizeof from_esn; | |
4976 | |
4977 to_fab.fab$l_fna = to; | |
4978 to_fab.fab$b_fns = strlen (to); | |
4979 to_fab.fab$l_nam = &to_nam; | |
4980 to_fab.fab$l_fop = FAB$M_NAM; | |
4981 | |
4982 to_nam.nam$l_esa = to_esn; | |
4983 to_nam.nam$b_ess = sizeof to_esn; | |
4984 | |
4985 status = SYS$RENAME (&from_fab, 0, 0, &to_fab); | |
4986 | |
4987 if (status & 1) | |
4988 return 0; | |
4989 else | |
4990 { | |
4991 if (status == RMS$_DEV) | |
4992 errno = EXDEV; | |
4993 else | |
4994 errno = EVMSERR; | |
4995 vaxc$errno = status; | |
4996 return -1; | |
4997 } | |
4998 } | |
4999 | |
5000 /* This function renames a file like `rename', but it strips | |
5001 the version number from the "to" filename, such that the "to" file is | |
5002 will always be a new version. It also sets the file protection once it is | |
5003 finished. The protection that we will use is stored in fab_final_pro, | |
5004 and was set when we did a creat_copy_attrs to create the file that we | |
5005 are renaming. | |
5006 | |
5007 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
|
5008 to describe the protection, and VMS uses 4 (write and delete are separate |
491 | 5009 bits). To maintain portability, the VMS implementation of `chmod' wires |
5010 the W and D bits together. */ | |
5011 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
5012 |
491 | 5013 static struct fibdef fib; /* We need this initialized to zero */ |
5014 char vms_file_written[NAM$C_MAXRSS]; | |
5015 | |
5016 int | |
5017 rename_sans_version (from,to) | |
5018 char *from, *to; | |
5019 { | |
5020 short int chan; | |
5021 int stat; | |
5022 short int iosb[4]; | |
5023 int status; | |
5024 struct FAB to_fab = cc$rms_fab; | |
5025 struct NAM to_nam = cc$rms_nam; | |
5026 struct dsc$descriptor fib_d ={sizeof (fib),0,0,(char*) &fib}; | |
5027 struct dsc$descriptor fib_attr[2] | |
5028 = {{sizeof (fab_final_pro),ATR$C_FPRO,0,(char*) &fab_final_pro},{0,0,0,0}}; | |
5029 char to_esn[NAM$C_MAXRSS]; | |
5030 | |
5031 $DESCRIPTOR (disk,to_esn); | |
5032 | |
5033 to_fab.fab$l_fna = to; | |
5034 to_fab.fab$b_fns = strlen (to); | |
5035 to_fab.fab$l_nam = &to_nam; | |
5036 to_fab.fab$l_fop = FAB$M_NAM; | |
5037 | |
5038 to_nam.nam$l_esa = to_esn; | |
5039 to_nam.nam$b_ess = sizeof to_esn; | |
5040 | |
5041 status = SYS$PARSE (&to_fab, 0, 0); /* figure out the full file name */ | |
5042 | |
5043 if (to_nam.nam$l_fnb && NAM$M_EXP_VER) | |
5044 *(to_nam.nam$l_ver) = '\0'; | |
5045 | |
5046 stat = rename (from, to_esn); | |
5047 if (stat < 0) | |
5048 return stat; | |
5049 | |
5050 strcpy (vms_file_written, to_esn); | |
5051 | |
5052 to_fab.fab$l_fna = vms_file_written; /* this points to the versionless name */ | |
5053 to_fab.fab$b_fns = strlen (vms_file_written); | |
5054 | |
5055 /* 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
|
5056 SYS$OPEN (&to_fab, 0, 0); /* This fills in the nam$w_fid fields */ |
491 | 5057 |
5058 /* Copy these fields into the fib */ | |
5059 fib.fib$r_fid_overlay.fib$w_fid[0] = to_nam.nam$w_fid[0]; | |
5060 fib.fib$r_fid_overlay.fib$w_fid[1] = to_nam.nam$w_fid[1]; | |
5061 fib.fib$r_fid_overlay.fib$w_fid[2] = to_nam.nam$w_fid[2]; | |
5062 | |
1596
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
5063 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
|
5064 |
0e105bd23f44
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1570
diff
changeset
|
5065 stat = SYS$ASSIGN (&disk, &chan, 0, 0); /* open a channel to the disk */ |
491 | 5066 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
|
5067 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
|
5068 stat = SYS$QIOW (0, chan, IO$_MODIFY, iosb, 0, 0, &fib_d, |
491 | 5069 0, 0, 0, &fib_attr, 0); |
5070 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
|
5071 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
|
5072 stat = SYS$DASSGN (chan); |
491 | 5073 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
|
5074 LIB$SIGNAL (stat); |
766 | 5075 strcpy (vms_file_written, to_esn); /* We will write this to the terminal*/ |
491 | 5076 return 0; |
5077 } | |
5078 | |
21514 | 5079 int |
491 | 5080 link (file, new) |
5081 char * file, * new; | |
5082 { | |
5083 register status; | |
5084 struct FAB fab; | |
5085 struct NAM nam; | |
5086 unsigned short fid[3]; | |
5087 char esa[NAM$C_MAXRSS]; | |
5088 | |
5089 fab = cc$rms_fab; | |
5090 fab.fab$l_fop = FAB$M_OFP; | |
5091 fab.fab$l_fna = file; | |
5092 fab.fab$b_fns = strlen (file); | |
5093 fab.fab$l_nam = &nam; | |
5094 | |
5095 nam = cc$rms_nam; | |
5096 nam.nam$l_esa = esa; | |
5097 nam.nam$b_ess = NAM$C_MAXRSS; | |
5098 | |
5099 status = SYS$PARSE (&fab); | |
5100 if ((status & 1) == 0) | |
5101 { | |
5102 errno = EVMSERR; | |
5103 vaxc$errno = status; | |
5104 return -1; | |
5105 } | |
5106 status = SYS$SEARCH (&fab); | |
5107 if ((status & 1) == 0) | |
5108 { | |
5109 errno = EVMSERR; | |
5110 vaxc$errno = status; | |
5111 return -1; | |
5112 } | |
5113 | |
5114 fid[0] = nam.nam$w_fid[0]; | |
5115 fid[1] = nam.nam$w_fid[1]; | |
5116 fid[2] = nam.nam$w_fid[2]; | |
5117 | |
5118 fab.fab$l_fna = new; | |
5119 fab.fab$b_fns = strlen (new); | |
5120 | |
5121 status = SYS$PARSE (&fab); | |
5122 if ((status & 1) == 0) | |
5123 { | |
5124 errno = EVMSERR; | |
5125 vaxc$errno = status; | |
5126 return -1; | |
5127 } | |
5128 | |
5129 nam.nam$w_fid[0] = fid[0]; | |
5130 nam.nam$w_fid[1] = fid[1]; | |
5131 nam.nam$w_fid[2] = fid[2]; | |
5132 | |
5133 nam.nam$l_esa = nam.nam$l_name; | |
5134 nam.nam$b_esl = nam.nam$b_name + nam.nam$b_type + nam.nam$b_ver; | |
5135 | |
5136 status = SYS$ENTER (&fab); | |
5137 if ((status & 1) == 0) | |
5138 { | |
5139 errno = EVMSERR; | |
5140 vaxc$errno = status; | |
5141 return -1; | |
5142 } | |
5143 | |
5144 return 0; | |
5145 } | |
5146 | |
21514 | 5147 void |
491 | 5148 croak (badfunc) |
5149 char *badfunc; | |
5150 { | |
5151 printf ("%s not yet implemented\r\n", badfunc); | |
53226
dd3018b4785b
Implemented multiple tty support.
Karoly Lorentey <lorentey@elte.hu>
parents:
53225
diff
changeset
|
5152 reset_all_sys_modes (); |
491 | 5153 exit (1); |
5154 } | |
5155 | |
5156 long | |
5157 random () | |
5158 { | |
5159 /* Arrange to return a range centered on zero. */ | |
5160 return rand () - (1 << 30); | |
5161 } | |
5162 | |
21514 | 5163 void |
491 | 5164 srandom (seed) |
5165 { | |
5166 srand (seed); | |
5167 } | |
5168 #endif /* VMS */ | |
5169 | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
5170 #ifdef AIXHFT |
491 | 5171 |
5172 /* Called from init_sys_modes. */ | |
21514 | 5173 void |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
5174 hft_init (struct tty_display_info *tty_out) |
491 | 5175 { |
5176 int junk; | |
5177 | |
5178 /* If we're not on an HFT we shouldn't do any of this. We determine | |
5179 if we are on an HFT by trying to get an HFT error code. If this | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48741
diff
changeset
|
5180 call fails, we're not on an HFT. */ |
491 | 5181 #ifdef IBMR2AIX |
5182 if (ioctl (0, HFQERROR, &junk) < 0) | |
5183 return; | |
5184 #else /* not IBMR2AIX */ | |
5185 if (ioctl (0, HFQEIO, 0) < 0) | |
5186 return; | |
5187 #endif /* not IBMR2AIX */ | |
5188 | |
5189 /* On AIX the default hft keyboard mapping uses backspace rather than delete | |
5190 as the rubout key's ASCII code. Here this is changed. The bug is that | |
5191 there's no way to determine the old mapping, so in reset_sys_modes | |
5192 we need to assume that the normal map had been present. Of course, this | |
5193 code also doesn't help if on a terminal emulator which doesn't understand | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
5194 HFT VTD's. */ |
491 | 5195 { |
5196 struct hfbuf buf; | |
5197 struct hfkeymap keymap; | |
5198 | |
5199 buf.hf_bufp = (char *)&keymap; | |
5200 buf.hf_buflen = sizeof (keymap); | |
5201 keymap.hf_nkeys = 2; | |
5202 keymap.hfkey[0].hf_kpos = 15; | |
5203 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
5204 #ifdef IBMR2AIX | |
5205 keymap.hfkey[0].hf_keyidh = '<'; | |
5206 #else /* not IBMR2AIX */ | |
5207 keymap.hfkey[0].hf_page = '<'; | |
5208 #endif /* not IBMR2AIX */ | |
5209 keymap.hfkey[0].hf_char = 127; | |
5210 keymap.hfkey[1].hf_kpos = 15; | |
5211 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
5212 #ifdef IBMR2AIX | |
5213 keymap.hfkey[1].hf_keyidh = '<'; | |
5214 #else /* not IBMR2AIX */ | |
5215 keymap.hfkey[1].hf_page = '<'; | |
5216 #endif /* not IBMR2AIX */ | |
5217 keymap.hfkey[1].hf_char = 127; | |
5218 hftctl (0, HFSKBD, &buf); | |
5219 } | |
5220 } | |
5221 | |
25578
4c9cf2c63703
[macintosh] (stat, fstat, mkdir, rmdir, utime, access)
Richard M. Stallman <rms@gnu.org>
parents:
25453
diff
changeset
|
5222 /* Reset the rubout key to backspace. */ |
491 | 5223 |
21514 | 5224 void |
82989
f3845715a5f6
Separate frame-local, tty-dependent parameters from tty-local parameters.
Karoly Lorentey <lorentey@elte.hu>
parents:
82988
diff
changeset
|
5225 hft_reset (struct tty_display_info *tty_out) |
491 | 5226 { |
5227 struct hfbuf buf; | |
5228 struct hfkeymap keymap; | |
5229 int junk; | |
5230 | |
5231 #ifdef IBMR2AIX | |
5232 if (ioctl (0, HFQERROR, &junk) < 0) | |
5233 return; | |
5234 #else /* not IBMR2AIX */ | |
5235 if (ioctl (0, HFQEIO, 0) < 0) | |
5236 return; | |
5237 #endif /* not IBMR2AIX */ | |
5238 | |
5239 buf.hf_bufp = (char *)&keymap; | |
5240 buf.hf_buflen = sizeof (keymap); | |
5241 keymap.hf_nkeys = 2; | |
5242 keymap.hfkey[0].hf_kpos = 15; | |
5243 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE; | |
5244 #ifdef IBMR2AIX | |
5245 keymap.hfkey[0].hf_keyidh = '<'; | |
5246 #else /* not IBMR2AIX */ | |
5247 keymap.hfkey[0].hf_page = '<'; | |
5248 #endif /* not IBMR2AIX */ | |
5249 keymap.hfkey[0].hf_char = 8; | |
5250 keymap.hfkey[1].hf_kpos = 15; | |
5251 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT; | |
5252 #ifdef IBMR2AIX | |
5253 keymap.hfkey[1].hf_keyidh = '<'; | |
5254 #else /* not IBMR2AIX */ | |
5255 keymap.hfkey[1].hf_page = '<'; | |
5256 #endif /* not IBMR2AIX */ | |
5257 keymap.hfkey[1].hf_char = 8; | |
5258 hftctl (0, HFSKBD, &buf); | |
5259 } | |
5260 | |
10049
aef1cc7e56a0
(init_sys_modes): Tes AIXHFT, not AIX.
Richard M. Stallman <rms@gnu.org>
parents:
9937
diff
changeset
|
5261 #endif /* AIXHFT */ |
9075
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5262 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5263 #ifdef USE_DL_STUBS |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5264 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5265 /* 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
|
5266 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
|
5267 actually call them. */ |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5268 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5269 void * |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5270 dlopen () |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5271 { |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5272 return 0; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5273 } |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5274 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5275 void * |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5276 dlsym () |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5277 { |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5278 return 0; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5279 } |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5280 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5281 int |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5282 dlclose () |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5283 { |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5284 return -1; |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5285 } |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5286 |
04b461c99a96
[USE_DL_STUBS] (dlopen, dlsym, dlclose): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
9039
diff
changeset
|
5287 #endif /* USE_DL_STUBS */ |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5288 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5289 #ifndef BSTRING |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5290 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5291 #ifndef bzero |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5292 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5293 void |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5294 bzero (b, length) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5295 register char *b; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5296 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5297 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5298 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5299 short zero = 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5300 long max_str = 65535; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5301 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5302 while (length > max_str) { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5303 (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
|
5304 length -= max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5305 b += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5306 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5307 max_str = length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5308 (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
|
5309 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5310 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5311 *b++ = 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5312 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5313 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5314 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5315 #endif /* no bzero */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5316 #endif /* BSTRING */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5317 |
11722
d7089b2620fb
(bcmp, bcopy): Fix backward BSTRING conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
11624
diff
changeset
|
5318 #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
|
5319 #undef bcopy |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5320 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5321 /* 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
|
5322 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
|
5323 bcopy (b1, b2, length) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5324 register char *b1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5325 register char *b2; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5326 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5327 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5328 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5329 long max_str = 65535; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5330 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5331 while (length > max_str) { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5332 (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
|
5333 length -= max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5334 b1 += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5335 b2 += max_str; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5336 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5337 max_str = length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5338 (void) LIB$MOVC3 (&length, b1, b2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5339 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5340 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5341 *b2++ = *b1++; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5342 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5343 } |
21514 | 5344 #endif /* (!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
|
5345 |
11722
d7089b2620fb
(bcmp, bcopy): Fix backward BSTRING conditionals.
Richard M. Stallman <rms@gnu.org>
parents:
11624
diff
changeset
|
5346 #ifndef BSTRING |
11258
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5347 #ifndef bcmp |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5348 int |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5349 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
|
5350 register char *b1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5351 register char *b2; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5352 register int length; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5353 { |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5354 #ifdef VMS |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5355 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
|
5356 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
|
5357 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5358 return STR$COMPARE (&src1, &src2); |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5359 #else |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5360 while (length-- > 0) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5361 if (*b1++ != *b2++) |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5362 return 1; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5363 |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5364 return 0; |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5365 #endif /* not VMS */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5366 } |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5367 #endif /* no bcmp */ |
eff46f465625
(bcopy): If NEED_BCOPY, do compile this.
Richard M. Stallman <rms@gnu.org>
parents:
10946
diff
changeset
|
5368 #endif /* not BSTRING */ |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5369 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5370 #ifndef HAVE_STRSIGNAL |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5371 char * |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5372 strsignal (code) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5373 int code; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5374 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5375 char *signame = 0; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5376 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5377 if (0 <= code && code < NSIG) |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5378 { |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5379 #ifdef VMS |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5380 signame = sys_errlist[code]; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5381 #else |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5382 /* Cast to suppress warning if the table has const char *. */ |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5383 signame = (char *) sys_siglist[code]; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5384 #endif |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5385 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5386 |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5387 return signame; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5388 } |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25674
diff
changeset
|
5389 #endif /* HAVE_STRSIGNAL */ |
32752
923b8d6d8277
Initial check-in: changes for building Emacs under Mac OS.
Andrew Choi <akochoi@shaw.ca>
parents:
32236
diff
changeset
|
5390 |
52401 | 5391 /* arch-tag: edb43589-4e09-4544-b325-978b5b121dcf |
5392 (do not change this comment) */ |