Mercurial > emacs
annotate src/process.c @ 43598:f49377cf2e3c
(Qconnect, Qfailed): New variables.
(syms_of_process): Intern and staticpro them.
[NON_BLOCKING_CONNECT]: New conditional.
(connect_wait_mask, num_pending_connects): New variables.
(status_message): Convert Qfailed status.
(Fopen_network_stream): Added support for non-blocking connect.
New optional args: filter, sentinel, non_blocking. Doc updated.
[HAVE_GETADDRINFO, !HAVE_GETADDRINFO]: Merged common code.
(deactivate_process): Handle pending non-blocking connect.
(wait_reading_process_input): Poll for status of non-blocking
connects. Exec sentinel directly when connect succeeds.
(status_notify): Don't read process output if not yet connected.
| author | Kim F. Storm <storm@cua.dk> |
|---|---|
| date | Thu, 28 Feb 2002 23:53:59 +0000 |
| parents | 93254645e03b |
| children | f21620032428 |
| rev | line source |
|---|---|
| 578 | 1 /* Asynchronous subprocess control for GNU Emacs. |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 98, 1999, |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3 2001, 2002 Free Software Foundation, Inc. |
| 578 | 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 | |
|
1780
d01c59bac5c1
* frame.h (FRAME_SAMPLE_VISIBILITY): Make sure frame is marked as
Jim Blandy <jimb@redhat.com>
parents:
1683
diff
changeset
|
9 the Free Software Foundation; either version 2, or (at your option) |
| 578 | 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:
14131
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:
14131
diff
changeset
|
20 Boston, MA 02111-1307, USA. */ |
| 578 | 21 |
| 22 | |
|
26313
9275b6adbad2
Undo last change and define _GNU_SOURCE before config.h.
Dave Love <fx@gnu.org>
parents:
26311
diff
changeset
|
23 #define _GNU_SOURCE /* to get strsignal declared with glibc 2 */ |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
24 #include <config.h> |
| 578 | 25 #include <signal.h> |
| 26 | |
| 588 | 27 /* This file is split into two parts by the following preprocessor |
| 28 conditional. The 'then' clause contains all of the support for | |
| 29 asynchronous subprocesses. The 'else' clause contains stub | |
| 30 versions of some of the asynchronous subprocess routines that are | |
| 31 often called elsewhere in Emacs, so we don't have to #ifdef the | |
| 32 sections that call them. */ | |
| 33 | |
| 34 | |
| 578 | 35 #ifdef subprocesses |
| 36 | |
| 37 #include <stdio.h> | |
| 38 #include <errno.h> | |
| 39 #include <setjmp.h> | |
| 40 #include <sys/types.h> /* some typedefs are used in sys/file.h */ | |
| 41 #include <sys/file.h> | |
| 42 #include <sys/stat.h> | |
| 6158 | 43 #ifdef HAVE_UNISTD_H |
| 44 #include <unistd.h> | |
| 45 #endif | |
| 578 | 46 |
|
29035
95e767e77a88
(toplevel) [UNIX98_PTYS]: Include stdlib.h.
Gerd Moellmann <gerd@gnu.org>
parents:
29017
diff
changeset
|
47 #if defined(WINDOWSNT) || defined(UNIX98_PTYS) |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
48 #include <stdlib.h> |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
49 #include <fcntl.h> |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
50 #endif /* not WINDOWSNT */ |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
51 |
| 578 | 52 #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ |
| 53 #include <sys/socket.h> | |
| 54 #include <netdb.h> | |
| 55 #include <netinet/in.h> | |
| 56 #include <arpa/inet.h> | |
|
12749
ce48ec025b0a
Maybe include net/errno.h.
Richard M. Stallman <rms@gnu.org>
parents:
12648
diff
changeset
|
57 #ifdef NEED_NET_ERRNO_H |
|
ce48ec025b0a
Maybe include net/errno.h.
Richard M. Stallman <rms@gnu.org>
parents:
12648
diff
changeset
|
58 #include <net/errno.h> |
|
ce48ec025b0a
Maybe include net/errno.h.
Richard M. Stallman <rms@gnu.org>
parents:
12648
diff
changeset
|
59 #endif /* NEED_NET_ERRNO_H */ |
| 578 | 60 #endif /* HAVE_SOCKETS */ |
| 61 | |
|
26313
9275b6adbad2
Undo last change and define _GNU_SOURCE before config.h.
Dave Love <fx@gnu.org>
parents:
26311
diff
changeset
|
62 /* TERM is a poor-man's SLIP, used on GNU/Linux. */ |
|
4914
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
63 #ifdef TERM |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
64 #include <client.h> |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
65 #endif |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
66 |
|
7238
c9598edda1a2
(IN_ADDR, NUMERIC_ADDR_ERROR): Made conditional on HAVE_BROKEN_INET_ADDR.
Paul Reilly <pmr@pajato.com>
parents:
7220
diff
changeset
|
67 /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */ |
|
c9598edda1a2
(IN_ADDR, NUMERIC_ADDR_ERROR): Made conditional on HAVE_BROKEN_INET_ADDR.
Paul Reilly <pmr@pajato.com>
parents:
7220
diff
changeset
|
68 #ifdef HAVE_BROKEN_INET_ADDR |
|
4998
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
69 #define IN_ADDR struct in_addr |
|
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
70 #define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1) |
|
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
71 #else |
|
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
72 #define IN_ADDR unsigned long |
|
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
73 #define NUMERIC_ADDR_ERROR (numeric_addr == -1) |
|
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
74 #endif |
|
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
75 |
|
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16206
diff
changeset
|
76 #if defined(BSD_SYSTEM) || defined(STRIDE) |
| 578 | 77 #include <sys/ioctl.h> |
|
1012
a48ed1d416dd
* process.c (process_send_signal): Don't send SIGTSTP if the
Jim Blandy <jimb@redhat.com>
parents:
849
diff
changeset
|
78 #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5) |
| 578 | 79 #include <fcntl.h> |
| 80 #endif /* HAVE_PTYS and no O_NDELAY */ | |
|
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16206
diff
changeset
|
81 #endif /* BSD_SYSTEM || STRIDE */ |
| 578 | 82 |
|
5240
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
83 #ifdef BROKEN_O_NONBLOCK |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
84 #undef O_NONBLOCK |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
85 #endif /* BROKEN_O_NONBLOCK */ |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
86 |
| 578 | 87 #ifdef NEED_BSDTTY |
| 88 #include <bsdtty.h> | |
| 89 #endif | |
| 90 | |
| 91 #ifdef IRIS | |
| 92 #include <sys/sysmacros.h> /* for "minor" */ | |
| 93 #endif /* not IRIS */ | |
| 94 | |
| 95 #include "systime.h" | |
|
1047
1ab1ed32e82a
* process.c: Include "systty.h", not "systerm.h".
Jim Blandy <jimb@redhat.com>
parents:
1030
diff
changeset
|
96 #include "systty.h" |
| 578 | 97 |
| 98 #include "lisp.h" | |
| 99 #include "window.h" | |
| 100 #include "buffer.h" | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
101 #include "charset.h" |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
102 #include "coding.h" |
| 578 | 103 #include "process.h" |
| 104 #include "termhooks.h" | |
| 105 #include "termopts.h" | |
| 106 #include "commands.h" | |
|
31099
0fe5afca71e4
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30582
diff
changeset
|
107 #include "keyboard.h" |
|
1780
d01c59bac5c1
* frame.h (FRAME_SAMPLE_VISIBILITY): Make sure frame is marked as
Jim Blandy <jimb@redhat.com>
parents:
1683
diff
changeset
|
108 #include "frame.h" |
| 16780 | 109 #include "blockinput.h" |
| 21514 | 110 #include "dispextern.h" |
| 26868 | 111 #include "composite.h" |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
112 #include "atimer.h" |
| 578 | 113 |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
114 Lisp_Object Qprocessp; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
115 Lisp_Object Qrun, Qstop, Qsignal; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
116 Lisp_Object Qopen, Qclosed, Qconnect, Qfailed; |
|
8231
5226ed89c1a6
(Qlast_nonmenu_event): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8063
diff
changeset
|
117 Lisp_Object Qlast_nonmenu_event; |
| 578 | 118 /* Qexit is declared and initialized in eval.c. */ |
| 119 | |
| 120 /* a process object is a network connection when its childp field is neither | |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
121 Qt nor Qnil but is instead a cons cell (HOSTNAME PORTNUM). */ |
| 578 | 122 |
| 123 #ifdef HAVE_SOCKETS | |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
124 #define NETCONN_P(p) (GC_CONSP (XPROCESS (p)->childp)) |
| 578 | 125 #else |
| 126 #define NETCONN_P(p) 0 | |
| 127 #endif /* HAVE_SOCKETS */ | |
| 128 | |
| 129 /* Define first descriptor number available for subprocesses. */ | |
| 130 #ifdef VMS | |
| 131 #define FIRST_PROC_DESC 1 | |
| 132 #else /* Not VMS */ | |
| 133 #define FIRST_PROC_DESC 3 | |
| 134 #endif | |
| 135 | |
| 136 /* Define SIGCHLD as an alias for SIGCLD. There are many conditionals | |
| 137 testing SIGCHLD. */ | |
| 138 | |
| 139 #if !defined (SIGCHLD) && defined (SIGCLD) | |
| 140 #define SIGCHLD SIGCLD | |
| 141 #endif /* SIGCLD */ | |
| 142 | |
| 143 #include "syssignal.h" | |
| 144 | |
| 4639 | 145 #include "syswait.h" |
| 578 | 146 |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
147 extern void set_waiting_for_input P_ ((EMACS_TIME *)); |
|
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
148 |
|
31099
0fe5afca71e4
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30582
diff
changeset
|
149 #ifndef USE_CRT_DLL |
| 5543 | 150 extern int errno; |
|
31099
0fe5afca71e4
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30582
diff
changeset
|
151 #endif |
| 5543 | 152 #ifdef VMS |
| 578 | 153 extern char *sys_errlist[]; |
| 5543 | 154 #endif |
| 578 | 155 |
|
8331
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
156 #ifndef HAVE_H_ERRNO |
|
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
157 extern int h_errno; |
|
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
158 #endif |
|
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
159 |
| 578 | 160 /* t means use pty, nil means use a pipe, |
| 161 maybe other values to come. */ | |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
162 static Lisp_Object Vprocess_connection_type; |
| 578 | 163 |
| 164 #ifdef SKTPAIR | |
| 165 #ifndef HAVE_SOCKETS | |
| 166 #include <sys/socket.h> | |
| 167 #endif | |
| 168 #endif /* SKTPAIR */ | |
| 169 | |
|
10548
dcae4394587d
(process_tick, update_tick): Make non-static.
Karl Heuer <kwzh@gnu.org>
parents:
10527
diff
changeset
|
170 /* These next two vars are non-static since sysdep.c uses them in the |
|
dcae4394587d
(process_tick, update_tick): Make non-static.
Karl Heuer <kwzh@gnu.org>
parents:
10527
diff
changeset
|
171 emulation of `select'. */ |
| 578 | 172 /* Number of events of change of status of a process. */ |
|
10548
dcae4394587d
(process_tick, update_tick): Make non-static.
Karl Heuer <kwzh@gnu.org>
parents:
10527
diff
changeset
|
173 int process_tick; |
| 578 | 174 /* Number of events for which the user or sentinel has been notified. */ |
|
10548
dcae4394587d
(process_tick, update_tick): Make non-static.
Karl Heuer <kwzh@gnu.org>
parents:
10527
diff
changeset
|
175 int update_tick; |
| 578 | 176 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
177 /* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
178 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
179 #ifdef BROKEN_NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
180 #undef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
181 #else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
182 #ifndef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
183 #ifdef HAVE_SOCKETS |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
184 #ifdef HAVE_SELECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
185 #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
186 #if defined (O_NONBLOCK) || defined (O_NDELAY) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
187 #if defined (EWOULDBLOCK) || defined (EINPROGRESS) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
188 #define NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
189 #endif /* EWOULDBLOCK || EINPROGRESS */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
190 #endif /* O_NONBLOCK || O_NDELAY */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
191 #endif /* HAVE_GETPEERNAME || GNU_LINUX */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
192 #endif /* HAVE_SELECT */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
193 #endif /* HAVE_SOCKETS */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
194 #endif /* NON_BLOCKING_CONNECT */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
195 #endif /* BROKEN_NON_BLOCKING_CONNECT */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
196 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
197 #ifdef TERM |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
198 #undef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
199 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
200 |
|
10527
68b8191091a7
#include sysselect.h instead of defining things by hand.
Karl Heuer <kwzh@gnu.org>
parents:
10032
diff
changeset
|
201 #include "sysselect.h" |
| 578 | 202 |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
203 extern int keyboard_bit_set P_ ((SELECT_TYPE *)); |
|
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
204 |
|
13414
b035c6e41457
[HAVE_NTGUI] (POLL_FOR_INPUT): Define macro.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13159
diff
changeset
|
205 /* If we support a window system, turn on the code to poll periodically |
|
7486
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
206 to detect C-g. It isn't actually used when doing interrupt input. */ |
|
13414
b035c6e41457
[HAVE_NTGUI] (POLL_FOR_INPUT): Define macro.
Geoff Voelker <voelker@cs.washington.edu>
parents:
13159
diff
changeset
|
207 #ifdef HAVE_WINDOW_SYSTEM |
|
7486
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
208 #define POLL_FOR_INPUT |
|
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
209 #endif |
|
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
210 |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
211 /* Mask of bits indicating the descriptors that we wait for input on. */ |
| 578 | 212 |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
213 static SELECT_TYPE input_wait_mask; |
|
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
214 |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
215 /* Mask that excludes keyboard input descriptor (s). */ |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
216 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
217 static SELECT_TYPE non_keyboard_wait_mask; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
218 |
|
17224
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
219 /* Mask that excludes process input descriptor (s). */ |
|
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
220 |
|
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
221 static SELECT_TYPE non_process_wait_mask; |
|
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
222 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
223 /* Mask of bits indicating the descriptors that we wait for connect to |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
224 complete on. Once they complete, they are removed from this mask |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
225 and added to the input_wait_mask and non_keyboard_wait_mask. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
226 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
227 static SELECT_TYPE connect_wait_mask; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
228 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
229 /* Number of bits set in connect_wait_mask. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
230 static int num_pending_connects; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
231 |
|
7044
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
232 /* The largest descriptor currently in use for a process object. */ |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
233 static int max_process_desc; |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
234 |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
235 /* The largest descriptor currently in use for keyboard input. */ |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
236 static int max_keyboard_desc; |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
237 |
|
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
238 /* Nonzero means delete a process right away if it exits. */ |
|
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
239 static int delete_exited_processes; |
| 578 | 240 |
| 241 /* Indexed by descriptor, gives the process (if any) for that descriptor */ | |
|
6164
d047d5a48e0e
(chan_process, Vprocess_alist): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
6158
diff
changeset
|
242 Lisp_Object chan_process[MAXDESC]; |
| 578 | 243 |
| 244 /* Alist of elements (NAME . PROCESS) */ | |
|
6164
d047d5a48e0e
(chan_process, Vprocess_alist): No longer static.
Richard M. Stallman <rms@gnu.org>
parents:
6158
diff
changeset
|
245 Lisp_Object Vprocess_alist; |
| 578 | 246 |
| 247 /* Buffered-ahead input char from process, indexed by channel. | |
| 248 -1 means empty (no char is buffered). | |
| 249 Used on sys V where the only way to tell if there is any | |
| 250 output from the process is to read at least one char. | |
| 251 Always -1 on systems that support FIONREAD. */ | |
| 252 | |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
253 /* Don't make static; need to access externally. */ |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
254 int proc_buffered_char[MAXDESC]; |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
255 |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
256 /* Table of `struct coding-system' for each process. */ |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
257 static struct coding_system *proc_decode_coding_system[MAXDESC]; |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
258 static struct coding_system *proc_encode_coding_system[MAXDESC]; |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
259 |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
260 static Lisp_Object get_process (); |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
261 static void exec_sentinel (); |
| 6158 | 262 |
|
14404
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
263 extern EMACS_TIME timer_check (); |
|
14785
e4a9806c1e83
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14758
diff
changeset
|
264 extern int timers_run; |
|
14404
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
265 |
| 6158 | 266 /* Maximum number of bytes to send to a pty without an eof. */ |
| 267 static int pty_max_bytes; | |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
268 |
|
21049
01e626b0a624
(Vdefault_file_name_coding_system): Extern it.
Kenichi Handa <handa@m17n.org>
parents:
20715
diff
changeset
|
269 extern Lisp_Object Vfile_name_coding_system, Vdefault_file_name_coding_system; |
|
19837
3bee81323f73
(create_process): Encode the new current dir.
Richard M. Stallman <rms@gnu.org>
parents:
19642
diff
changeset
|
270 |
|
11609
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
271 #ifdef HAVE_PTYS |
|
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
272 /* The file name of the pty opened by allocate_pty. */ |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
273 |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
274 static char pty_name[24]; |
|
11609
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
275 #endif |
| 578 | 276 |
| 277 /* Compute the Lisp form of the process status, p->status, from | |
| 278 the numeric status that was returned by `wait'. */ | |
| 279 | |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
280 Lisp_Object status_convert (); |
|
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
281 |
| 21514 | 282 void |
| 578 | 283 update_status (p) |
| 284 struct Lisp_Process *p; | |
| 285 { | |
| 286 union { int i; WAITTYPE wt; } u; | |
| 287 u.i = XFASTINT (p->raw_status_low) + (XFASTINT (p->raw_status_high) << 16); | |
| 288 p->status = status_convert (u.wt); | |
| 289 p->raw_status_low = Qnil; | |
| 290 p->raw_status_high = Qnil; | |
| 291 } | |
| 292 | |
| 3608 | 293 /* Convert a process status word in Unix format to |
| 578 | 294 the list that we use internally. */ |
| 295 | |
| 296 Lisp_Object | |
| 297 status_convert (w) | |
| 298 WAITTYPE w; | |
| 299 { | |
| 300 if (WIFSTOPPED (w)) | |
| 301 return Fcons (Qstop, Fcons (make_number (WSTOPSIG (w)), Qnil)); | |
| 302 else if (WIFEXITED (w)) | |
| 303 return Fcons (Qexit, Fcons (make_number (WRETCODE (w)), | |
| 304 WCOREDUMP (w) ? Qt : Qnil)); | |
| 305 else if (WIFSIGNALED (w)) | |
| 306 return Fcons (Qsignal, Fcons (make_number (WTERMSIG (w)), | |
| 307 WCOREDUMP (w) ? Qt : Qnil)); | |
| 308 else | |
| 309 return Qrun; | |
| 310 } | |
| 311 | |
| 312 /* Given a status-list, extract the three pieces of information | |
| 313 and store them individually through the three pointers. */ | |
| 314 | |
| 315 void | |
| 316 decode_status (l, symbol, code, coredump) | |
| 317 Lisp_Object l; | |
| 318 Lisp_Object *symbol; | |
| 319 int *code; | |
| 320 int *coredump; | |
| 321 { | |
| 322 Lisp_Object tem; | |
| 323 | |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
324 if (SYMBOLP (l)) |
| 578 | 325 { |
| 326 *symbol = l; | |
| 327 *code = 0; | |
| 328 *coredump = 0; | |
| 329 } | |
| 330 else | |
| 331 { | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
332 *symbol = XCAR (l); |
|
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
333 tem = XCDR (l); |
|
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
334 *code = XFASTINT (XCAR (tem)); |
|
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
335 tem = XCDR (tem); |
| 578 | 336 *coredump = !NILP (tem); |
| 337 } | |
| 338 } | |
| 339 | |
| 340 /* Return a string describing a process status list. */ | |
| 341 | |
| 342 Lisp_Object | |
| 343 status_message (status) | |
| 344 Lisp_Object status; | |
| 345 { | |
| 346 Lisp_Object symbol; | |
| 347 int code, coredump; | |
| 348 Lisp_Object string, string2; | |
| 349 | |
| 350 decode_status (status, &symbol, &code, &coredump); | |
| 351 | |
| 352 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop)) | |
| 353 { | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
354 char *signame; |
|
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26313
diff
changeset
|
355 synchronize_system_messages_locale (); |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
356 signame = strsignal (code); |
|
5579
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
357 if (signame == 0) |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
358 signame = "unknown"; |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
359 string = build_string (signame); |
| 578 | 360 string2 = build_string (coredump ? " (core dumped)\n" : "\n"); |
| 361 XSTRING (string)->data[0] = DOWNCASE (XSTRING (string)->data[0]); | |
| 362 return concat2 (string, string2); | |
| 363 } | |
| 364 else if (EQ (symbol, Qexit)) | |
| 365 { | |
| 366 if (code == 0) | |
| 367 return build_string ("finished\n"); | |
|
2429
96b55f2f19cd
Rename int-to-string to number-to-string, since it can handle
Jim Blandy <jimb@redhat.com>
parents:
2357
diff
changeset
|
368 string = Fnumber_to_string (make_number (code)); |
| 578 | 369 string2 = build_string (coredump ? " (core dumped)\n" : "\n"); |
| 370 return concat2 (build_string ("exited abnormally with code "), | |
| 371 concat2 (string, string2)); | |
| 372 } | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
373 else if (EQ (symbol, Qfailed)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
374 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
375 string = Fnumber_to_string (make_number (code)); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
376 string2 = build_string ("\n"); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
377 return concat2 (build_string ("failed with code "), |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
378 concat2 (string, string2)); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
379 } |
| 578 | 380 else |
| 381 return Fcopy_sequence (Fsymbol_name (symbol)); | |
| 382 } | |
| 383 | |
| 384 #ifdef HAVE_PTYS | |
| 385 | |
|
11609
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
386 /* Open an available pty, returning a file descriptor. |
|
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
387 Return -1 on failure. |
|
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
388 The file name of the terminal corresponding to the pty |
|
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
389 is left in the variable pty_name. */ |
|
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
390 |
| 578 | 391 int |
| 392 allocate_pty () | |
| 393 { | |
| 394 struct stat stb; | |
| 21514 | 395 register int c, i; |
| 578 | 396 int fd; |
| 397 | |
| 624 | 398 /* Some systems name their pseudoterminals so that there are gaps in |
| 399 the usual sequence - for example, on HP9000/S700 systems, there | |
| 400 are no pseudoterminals with names ending in 'f'. So we wait for | |
| 401 three failures in a row before deciding that we've reached the | |
| 402 end of the ptys. */ | |
| 403 int failed_count = 0; | |
| 404 | |
| 578 | 405 #ifdef PTY_ITERATION |
| 406 PTY_ITERATION | |
| 407 #else | |
| 408 for (c = FIRST_PTY_LETTER; c <= 'z'; c++) | |
| 409 for (i = 0; i < 16; i++) | |
| 410 #endif | |
| 411 { | |
| 412 #ifdef PTY_NAME_SPRINTF | |
| 413 PTY_NAME_SPRINTF | |
| 414 #else | |
| 415 sprintf (pty_name, "/dev/pty%c%x", c, i); | |
| 416 #endif /* no PTY_NAME_SPRINTF */ | |
| 417 | |
|
822
c6e94e13926c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
808
diff
changeset
|
418 #ifdef PTY_OPEN |
|
c6e94e13926c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
808
diff
changeset
|
419 PTY_OPEN; |
|
c6e94e13926c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
808
diff
changeset
|
420 #else /* no PTY_OPEN */ |
| 624 | 421 #ifdef IRIS |
| 422 /* Unusual IRIS code */ | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
423 *ptyv = emacs_open ("/dev/ptc", O_RDWR | O_NDELAY, 0); |
| 624 | 424 if (fd < 0) |
| 425 return -1; | |
| 426 if (fstat (fd, &stb) < 0) | |
| 427 return -1; | |
|
822
c6e94e13926c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
808
diff
changeset
|
428 #else /* not IRIS */ |
| 578 | 429 if (stat (pty_name, &stb) < 0) |
| 624 | 430 { |
| 431 failed_count++; | |
| 432 if (failed_count >= 3) | |
| 433 return -1; | |
| 434 } | |
| 435 else | |
| 436 failed_count = 0; | |
| 578 | 437 #ifdef O_NONBLOCK |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
438 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
| 578 | 439 #else |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
440 fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); |
| 578 | 441 #endif |
|
822
c6e94e13926c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
808
diff
changeset
|
442 #endif /* not IRIS */ |
|
c6e94e13926c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
808
diff
changeset
|
443 #endif /* no PTY_OPEN */ |
| 578 | 444 |
| 445 if (fd >= 0) | |
| 446 { | |
| 447 /* check to make certain that both sides are available | |
| 448 this avoids a nasty yet stupid bug in rlogins */ | |
| 449 #ifdef PTY_TTY_NAME_SPRINTF | |
| 450 PTY_TTY_NAME_SPRINTF | |
| 451 #else | |
| 452 sprintf (pty_name, "/dev/tty%c%x", c, i); | |
| 453 #endif /* no PTY_TTY_NAME_SPRINTF */ | |
| 454 #ifndef UNIPLUS | |
| 455 if (access (pty_name, 6) != 0) | |
| 456 { | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
457 emacs_close (fd); |
|
2887
0554478bfa71
* process.c [__sgi] (allocate_pty): Give up immediately if pty is
Jim Blandy <jimb@redhat.com>
parents:
2830
diff
changeset
|
458 #if !defined(IRIS) && !defined(__sgi) |
| 578 | 459 continue; |
| 460 #else | |
| 461 return -1; | |
| 462 #endif /* IRIS */ | |
| 463 } | |
| 464 #endif /* not UNIPLUS */ | |
| 465 setup_pty (fd); | |
| 466 return fd; | |
| 467 } | |
| 468 } | |
| 469 return -1; | |
| 470 } | |
| 471 #endif /* HAVE_PTYS */ | |
| 472 | |
| 473 Lisp_Object | |
| 474 make_process (name) | |
| 475 Lisp_Object name; | |
| 476 { | |
| 477 register Lisp_Object val, tem, name1; | |
| 478 register struct Lisp_Process *p; | |
| 479 char suffix[10]; | |
| 480 register int i; | |
| 481 | |
|
36434
40cfe4976f04
(make_process): Use allocate_process.
Gerd Moellmann <gerd@gnu.org>
parents:
35336
diff
changeset
|
482 p = allocate_process (); |
|
9969
007d93b04e1f
(make_process): Use allocate_vectorlike and VECSIZE.
Karl Heuer <kwzh@gnu.org>
parents:
9952
diff
changeset
|
483 |
|
9277
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
484 XSETINT (p->infd, -1); |
|
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
485 XSETINT (p->outfd, -1); |
|
9318
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
486 XSETFASTINT (p->pid, 0); |
|
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
487 XSETFASTINT (p->tick, 0); |
|
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
488 XSETFASTINT (p->update_tick, 0); |
| 578 | 489 p->raw_status_low = Qnil; |
| 490 p->raw_status_high = Qnil; | |
| 491 p->status = Qrun; | |
| 492 p->mark = Fmake_marker (); | |
| 493 | |
| 494 /* If name is already in use, modify it until it is unused. */ | |
| 495 | |
| 496 name1 = name; | |
| 497 for (i = 1; ; i++) | |
| 498 { | |
| 499 tem = Fget_process (name1); | |
| 500 if (NILP (tem)) break; | |
| 501 sprintf (suffix, "<%d>", i); | |
| 502 name1 = concat2 (name, build_string (suffix)); | |
| 503 } | |
| 504 name = name1; | |
| 505 p->name = name; | |
|
9969
007d93b04e1f
(make_process): Use allocate_vectorlike and VECSIZE.
Karl Heuer <kwzh@gnu.org>
parents:
9952
diff
changeset
|
506 XSETPROCESS (val, p); |
| 578 | 507 Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist); |
| 508 return val; | |
| 509 } | |
| 510 | |
| 21514 | 511 void |
| 578 | 512 remove_process (proc) |
| 513 register Lisp_Object proc; | |
| 514 { | |
| 515 register Lisp_Object pair; | |
| 516 | |
| 517 pair = Frassq (proc, Vprocess_alist); | |
| 518 Vprocess_alist = Fdelq (pair, Vprocess_alist); | |
| 519 | |
| 520 deactivate_process (proc); | |
| 521 } | |
| 522 | |
| 523 DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
524 doc: /* Return t if OBJECT is a process. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
525 (object) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
526 Lisp_Object object; |
| 578 | 527 { |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
528 return PROCESSP (object) ? Qt : Qnil; |
| 578 | 529 } |
| 530 | |
| 531 DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
532 doc: /* Return the process named NAME, or nil if there is none. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
533 (name) |
| 578 | 534 register Lisp_Object name; |
| 535 { | |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
536 if (PROCESSP (name)) |
| 578 | 537 return name; |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
538 CHECK_STRING (name); |
| 578 | 539 return Fcdr (Fassoc (name, Vprocess_alist)); |
| 540 } | |
| 541 | |
| 542 DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
543 doc: /* Return the (or a) process associated with BUFFER. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
544 BUFFER may be a buffer or the name of one. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
545 (buffer) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
546 register Lisp_Object buffer; |
| 578 | 547 { |
| 548 register Lisp_Object buf, tail, proc; | |
| 549 | |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
550 if (NILP (buffer)) return Qnil; |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
551 buf = Fget_buffer (buffer); |
| 578 | 552 if (NILP (buf)) return Qnil; |
| 553 | |
| 554 for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail)) | |
| 555 { | |
| 556 proc = Fcdr (Fcar (tail)); | |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
557 if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf)) |
| 578 | 558 return proc; |
| 559 } | |
| 560 return Qnil; | |
| 561 } | |
| 562 | |
| 808 | 563 /* This is how commands for the user decode process arguments. It |
| 564 accepts a process, a process name, a buffer, a buffer name, or nil. | |
| 565 Buffers denote the first process in the buffer, and nil denotes the | |
| 566 current buffer. */ | |
| 578 | 567 |
|
4994
4146a65b9f02
(get_process): Add `static' to definition.
Richard M. Stallman <rms@gnu.org>
parents:
4914
diff
changeset
|
568 static Lisp_Object |
| 578 | 569 get_process (name) |
| 570 register Lisp_Object name; | |
| 571 { | |
|
6313
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
572 register Lisp_Object proc, obj; |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
573 if (STRINGP (name)) |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
574 { |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
575 obj = Fget_process (name); |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
576 if (NILP (obj)) |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
577 obj = Fget_buffer (name); |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
578 if (NILP (obj)) |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
579 error ("Process %s does not exist", XSTRING (name)->data); |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
580 } |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
581 else if (NILP (name)) |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
582 obj = Fcurrent_buffer (); |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
583 else |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
584 obj = name; |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
585 |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
586 /* Now obj should be either a buffer object or a process object. |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
587 */ |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
588 if (BUFFERP (obj)) |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
589 { |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
590 proc = Fget_buffer_process (obj); |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
591 if (NILP (proc)) |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
592 error ("Buffer %s has no process", XSTRING (XBUFFER (obj)->name)->data); |
|
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
593 } |
| 578 | 594 else |
| 595 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
596 CHECK_PROCESS (obj); |
|
6313
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
597 proc = obj; |
| 578 | 598 } |
|
6313
9a6531e6de5d
(get_process): Allow arg to be a buffer object.
Karl Heuer <kwzh@gnu.org>
parents:
6253
diff
changeset
|
599 return proc; |
| 578 | 600 } |
| 601 | |
| 602 DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
603 doc: /* Delete PROCESS: kill it and forget about it immediately. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
604 PROCESS may be a process, a buffer, the name of a process or buffer, or |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
605 nil, indicating the current buffer's process. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
606 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
607 register Lisp_Object process; |
| 578 | 608 { |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
609 process = get_process (process); |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
610 XPROCESS (process)->raw_status_low = Qnil; |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
611 XPROCESS (process)->raw_status_high = Qnil; |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
612 if (NETCONN_P (process)) |
| 578 | 613 { |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
614 XPROCESS (process)->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
615 XSETINT (XPROCESS (process)->tick, ++process_tick); |
| 578 | 616 } |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
617 else if (XINT (XPROCESS (process)->infd) >= 0) |
| 578 | 618 { |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
619 Fkill_process (process, Qnil); |
| 578 | 620 /* Do this now, since remove_process will make sigchld_handler do nothing. */ |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
621 XPROCESS (process)->status |
| 578 | 622 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
623 XSETINT (XPROCESS (process)->tick, ++process_tick); |
| 578 | 624 status_notify (); |
| 625 } | |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
626 remove_process (process); |
| 578 | 627 return Qnil; |
| 628 } | |
| 629 | |
| 630 DEFUN ("process-status", Fprocess_status, Sprocess_status, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
631 doc: /* Return the status of PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
632 The returned value is one of the following symbols: |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
633 run -- for a process that is running. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
634 stop -- for a process stopped but continuable. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
635 exit -- for a process that has exited. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
636 signal -- for a process that has got a fatal signal. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
637 open -- for a network stream connection that is open. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
638 closed -- for a network stream connection that is closed. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
639 nil -- if arg is a process name and no such process exists. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
640 PROCESS may be a process, a buffer, the name of a process, or |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
641 nil, indicating the current buffer's process. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
642 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
643 register Lisp_Object process; |
| 578 | 644 { |
| 645 register struct Lisp_Process *p; | |
| 646 register Lisp_Object status; | |
|
7937
bf963799d8be
(Fprocess_status): Return nil for process name that has no process.
Richard M. Stallman <rms@gnu.org>
parents:
7893
diff
changeset
|
647 |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
648 if (STRINGP (process)) |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
649 process = Fget_process (process); |
|
7937
bf963799d8be
(Fprocess_status): Return nil for process name that has no process.
Richard M. Stallman <rms@gnu.org>
parents:
7893
diff
changeset
|
650 else |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
651 process = get_process (process); |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
652 |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
653 if (NILP (process)) |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
654 return process; |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
655 |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
656 p = XPROCESS (process); |
| 578 | 657 if (!NILP (p->raw_status_low)) |
| 658 update_status (p); | |
| 659 status = p->status; | |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
660 if (CONSP (status)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
661 status = XCAR (status); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
662 if (NETCONN_P (process)) |
| 578 | 663 { |
| 664 if (EQ (status, Qrun)) | |
| 665 status = Qopen; | |
| 666 else if (EQ (status, Qexit)) | |
| 667 status = Qclosed; | |
| 668 } | |
| 669 return status; | |
| 670 } | |
| 671 | |
| 672 DEFUN ("process-exit-status", Fprocess_exit_status, Sprocess_exit_status, | |
| 673 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
674 doc: /* Return the exit status of PROCESS or the signal number that killed it. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
675 If PROCESS has not yet exited or died, return 0. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
676 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
677 register Lisp_Object process; |
| 578 | 678 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
679 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
680 if (!NILP (XPROCESS (process)->raw_status_low)) |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
681 update_status (XPROCESS (process)); |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
682 if (CONSP (XPROCESS (process)->status)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
683 return XCAR (XCDR (XPROCESS (process)->status)); |
| 578 | 684 return make_number (0); |
| 685 } | |
| 686 | |
| 687 DEFUN ("process-id", Fprocess_id, Sprocess_id, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
688 doc: /* Return the process id of PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
689 This is the pid of the Unix process which PROCESS uses or talks to. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
690 For a network connection, this value is nil. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
691 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
692 register Lisp_Object process; |
| 578 | 693 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
694 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
695 return XPROCESS (process)->pid; |
| 578 | 696 } |
| 697 | |
| 698 DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
699 doc: /* Return the name of PROCESS, as a string. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
700 This is the name of the program invoked in PROCESS, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
701 possibly modified to make it unique among process names. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
702 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
703 register Lisp_Object process; |
| 578 | 704 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
705 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
706 return XPROCESS (process)->name; |
| 578 | 707 } |
| 708 | |
| 709 DEFUN ("process-command", Fprocess_command, Sprocess_command, 1, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
710 doc: /* Return the command that was executed to start PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
711 This is a list of strings, the first string being the program executed |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
712 and the rest of the strings being the arguments given to it. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
713 For a non-child channel, this is nil. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
714 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
715 register Lisp_Object process; |
| 578 | 716 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
717 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
718 return XPROCESS (process)->command; |
| 578 | 719 } |
| 720 | |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
721 DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
722 doc: /* Return the name of the terminal PROCESS uses, or nil if none. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
723 This is the terminal that the process itself reads and writes on, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
724 not the name of the pty that Emacs uses to talk with that terminal. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
725 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
726 register Lisp_Object process; |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
727 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
728 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
729 return XPROCESS (process)->tty_name; |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
730 } |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
731 |
| 578 | 732 DEFUN ("set-process-buffer", Fset_process_buffer, Sset_process_buffer, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
733 2, 2, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
734 doc: /* Set buffer associated with PROCESS to BUFFER (a buffer, or nil). */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
735 (process, buffer) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
736 register Lisp_Object process, buffer; |
| 578 | 737 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
738 CHECK_PROCESS (process); |
| 578 | 739 if (!NILP (buffer)) |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
740 CHECK_BUFFER (buffer); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
741 XPROCESS (process)->buffer = buffer; |
| 578 | 742 return buffer; |
| 743 } | |
| 744 | |
| 745 DEFUN ("process-buffer", Fprocess_buffer, Sprocess_buffer, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
746 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
747 doc: /* Return the buffer PROCESS is associated with. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
748 Output from PROCESS is inserted in this buffer unless PROCESS has a filter. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
749 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
750 register Lisp_Object process; |
| 578 | 751 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
752 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
753 return XPROCESS (process)->buffer; |
| 578 | 754 } |
| 755 | |
| 756 DEFUN ("process-mark", Fprocess_mark, Sprocess_mark, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
757 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
758 doc: /* Return the marker for the end of the last output from PROCESS. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
759 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
760 register Lisp_Object process; |
| 578 | 761 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
762 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
763 return XPROCESS (process)->mark; |
| 578 | 764 } |
| 765 | |
| 766 DEFUN ("set-process-filter", Fset_process_filter, Sset_process_filter, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
767 2, 2, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
768 doc: /* Give PROCESS the filter function FILTER; nil means no filter. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
769 t means stop accepting output from the process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
770 When a process has a filter, each time it does output |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
771 the entire string of output is passed to the filter. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
772 The filter gets two arguments: the process and the string of output. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
773 If the process has a filter, its buffer is not used for output. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
774 (process, filter) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
775 register Lisp_Object process, filter; |
| 578 | 776 { |
|
36623
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
777 struct Lisp_Process *p; |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
778 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
779 CHECK_PROCESS (process); |
|
36623
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
780 p = XPROCESS (process); |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
781 |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
782 /* Don't signal an error if the process' input file descriptor |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
783 is closed. This could make debugging Lisp more difficult, |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
784 for example when doing something like |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
785 |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
786 (setq process (start-process ...)) |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
787 (debug) |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
788 (set-process-filter process ...) */ |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
789 |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
790 if (XINT (p->infd) >= 0) |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
791 { |
|
36623
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
792 if (EQ (filter, Qt)) |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
793 { |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
794 FD_CLR (XINT (p->infd), &input_wait_mask); |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
795 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
796 } |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
797 else if (EQ (XPROCESS (process)->filter, Qt)) |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
798 { |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
799 FD_SET (XINT (p->infd), &input_wait_mask); |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
800 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
801 } |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
802 } |
|
36623
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
803 |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
804 p->filter = filter; |
| 578 | 805 return filter; |
| 806 } | |
| 807 | |
| 808 DEFUN ("process-filter", Fprocess_filter, Sprocess_filter, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
809 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
810 doc: /* Returns the filter function of PROCESS; nil if none. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
811 See `set-process-filter' for more info on filter functions. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
812 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
813 register Lisp_Object process; |
| 578 | 814 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
815 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
816 return XPROCESS (process)->filter; |
| 578 | 817 } |
| 818 | |
| 819 DEFUN ("set-process-sentinel", Fset_process_sentinel, Sset_process_sentinel, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
820 2, 2, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
821 doc: /* Give PROCESS the sentinel SENTINEL; nil for none. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
822 The sentinel is called as a function when the process changes state. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
823 It gets two arguments: the process, and a string describing the change. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
824 (process, sentinel) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
825 register Lisp_Object process, sentinel; |
| 578 | 826 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
827 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
828 XPROCESS (process)->sentinel = sentinel; |
| 578 | 829 return sentinel; |
| 830 } | |
| 831 | |
| 832 DEFUN ("process-sentinel", Fprocess_sentinel, Sprocess_sentinel, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
833 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
834 doc: /* Return the sentinel of PROCESS; nil if none. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
835 See `set-process-sentinel' for more info on sentinels. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
836 (process) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
837 register Lisp_Object process; |
| 578 | 838 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
839 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
840 return XPROCESS (process)->sentinel; |
| 578 | 841 } |
| 842 | |
|
6830
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
843 DEFUN ("set-process-window-size", Fset_process_window_size, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
844 Sset_process_window_size, 3, 3, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
845 doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
846 (process, height, width) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
847 register Lisp_Object process, height, width; |
|
6830
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
848 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
849 CHECK_PROCESS (process); |
|
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
850 CHECK_NATNUM (height); |
|
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
851 CHECK_NATNUM (width); |
|
36623
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
852 |
|
36659
c1c5ad73f700
(Fset_process_window_size): Fix a typo.
Gerd Moellmann <gerd@gnu.org>
parents:
36623
diff
changeset
|
853 if (XINT (XPROCESS (process)->infd) < 0 |
|
36623
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
854 || set_window_size (XINT (XPROCESS (process)->infd), |
|
9fde2182c68a
(Fset_process_filter): Don't crash if the input
Gerd Moellmann <gerd@gnu.org>
parents:
36434
diff
changeset
|
855 XINT (height), XINT (width)) <= 0) |
|
6830
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
856 return Qnil; |
|
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
857 else |
|
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
858 return Qt; |
|
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
859 } |
|
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
860 |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
861 DEFUN ("set-process-inherit-coding-system-flag", |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
862 Fset_process_inherit_coding_system_flag, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
863 Sset_process_inherit_coding_system_flag, 2, 2, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
864 doc: /* Determine whether buffer of PROCESS will inherit coding-system. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
865 If the second argument FLAG is non-nil, then the variable |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
866 `buffer-file-coding-system' of the buffer associated with PROCESS |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
867 will be bound to the value of the coding system used to decode |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
868 the process output. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
869 |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
870 This is useful when the coding system specified for the process buffer |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
871 leaves either the character code conversion or the end-of-line conversion |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
872 unspecified, or if the coding system used to decode the process output |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
873 is more appropriate for saving the process buffer. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
874 |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
875 Binding the variable `inherit-process-coding-system' to non-nil before |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
876 starting the process is an alternative way of setting the inherit flag |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
877 for the process which will run. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
878 (process, flag) |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
879 register Lisp_Object process, flag; |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
880 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
881 CHECK_PROCESS (process); |
|
21848
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
882 XPROCESS (process)->inherit_coding_system_flag = flag; |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
883 return flag; |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
884 } |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
885 |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
886 DEFUN ("process-inherit-coding-system-flag", |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
887 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
888 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
889 doc: /* Return the value of inherit-coding-system flag for PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
890 If this flag is t, `buffer-file-coding-system' of the buffer |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
891 associated with PROCESS will inherit the coding system used to decode |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
892 the process output. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
893 (process) |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
894 register Lisp_Object process; |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
895 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
896 CHECK_PROCESS (process); |
|
21848
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
897 return XPROCESS (process)->inherit_coding_system_flag; |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
898 } |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
899 |
| 578 | 900 DEFUN ("process-kill-without-query", Fprocess_kill_without_query, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
901 Sprocess_kill_without_query, 1, 2, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
902 doc: /* Say no query needed if PROCESS is running when Emacs is exited. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
903 Optional second argument if non-nil says to require a query. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
904 Value is t if a query was formerly required. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
905 (process, value) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
906 register Lisp_Object process, value; |
| 578 | 907 { |
| 908 Lisp_Object tem; | |
| 909 | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
910 CHECK_PROCESS (process); |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
911 tem = XPROCESS (process)->kill_without_query; |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
912 XPROCESS (process)->kill_without_query = Fnull (value); |
| 578 | 913 |
| 914 return Fnull (tem); | |
| 915 } | |
|
4231
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
916 |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
917 DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
918 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
919 doc: /* Return the contact info of PROCESS; t for a real child. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
920 For a net connection, the value is a cons cell of the form (HOST SERVICE). */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
921 (process) |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
922 register Lisp_Object process; |
|
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
923 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
924 CHECK_PROCESS (process); |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
925 return XPROCESS (process)->childp; |
|
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
926 } |
|
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
927 |
|
4231
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
928 #if 0 /* Turned off because we don't currently record this info |
|
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
929 in the process. Perhaps add it. */ |
|
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
930 DEFUN ("process-connection", Fprocess_connection, Sprocess_connection, 1, 1, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
931 doc: /* Return the connection type of PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
932 The value is nil for a pipe, t or `pty' for a pty, or `stream' for |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
933 a socket connection. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
934 (process) |
|
4231
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
935 Lisp_Object process; |
|
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
936 { |
|
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
937 return XPROCESS (process)->type; |
|
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
938 } |
|
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
939 #endif |
| 578 | 940 |
| 941 Lisp_Object | |
| 942 list_processes_1 () | |
| 943 { | |
| 944 register Lisp_Object tail, tem; | |
| 945 Lisp_Object proc, minspace, tem1; | |
| 946 register struct Lisp_Process *p; | |
| 947 char tembuf[80]; | |
| 948 | |
|
9318
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
949 XSETFASTINT (minspace, 1); |
| 578 | 950 |
| 951 set_buffer_internal (XBUFFER (Vstandard_output)); | |
| 952 Fbuffer_disable_undo (Vstandard_output); | |
| 953 | |
| 954 current_buffer->truncate_lines = Qt; | |
| 955 | |
| 956 write_string ("\ | |
|
9697
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
957 Proc Status Buffer Tty Command\n\ |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
958 ---- ------ ------ --- -------\n", -1); |
| 578 | 959 |
| 960 for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail)) | |
| 961 { | |
| 962 Lisp_Object symbol; | |
| 963 | |
| 964 proc = Fcdr (Fcar (tail)); | |
| 965 p = XPROCESS (proc); | |
| 966 if (NILP (p->childp)) | |
| 967 continue; | |
| 968 | |
| 969 Finsert (1, &p->name); | |
| 970 Findent_to (make_number (13), minspace); | |
| 971 | |
| 972 if (!NILP (p->raw_status_low)) | |
| 973 update_status (p); | |
| 974 symbol = p->status; | |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
975 if (CONSP (p->status)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
976 symbol = XCAR (p->status); |
| 578 | 977 |
| 978 | |
| 979 if (EQ (symbol, Qsignal)) | |
| 980 { | |
| 981 Lisp_Object tem; | |
| 982 tem = Fcar (Fcdr (p->status)); | |
| 983 #ifdef VMS | |
| 984 if (XINT (tem) < NSIG) | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
985 write_string (sys_errlist [XINT (tem)], -1); |
| 578 | 986 else |
| 987 #endif | |
| 988 Fprinc (symbol, Qnil); | |
| 989 } | |
| 990 else if (NETCONN_P (proc)) | |
| 991 { | |
| 992 if (EQ (symbol, Qrun)) | |
| 993 write_string ("open", -1); | |
| 994 else if (EQ (symbol, Qexit)) | |
| 995 write_string ("closed", -1); | |
| 996 else | |
| 997 Fprinc (symbol, Qnil); | |
| 998 } | |
| 999 else | |
| 1000 Fprinc (symbol, Qnil); | |
| 1001 | |
| 1002 if (EQ (symbol, Qexit)) | |
| 1003 { | |
| 1004 Lisp_Object tem; | |
| 1005 tem = Fcar (Fcdr (p->status)); | |
| 1006 if (XFASTINT (tem)) | |
| 1007 { | |
|
11695
0f9b9c375416
(list_processes_1): Cast XFASTINT for passing to sprintf.
Richard M. Stallman <rms@gnu.org>
parents:
11609
diff
changeset
|
1008 sprintf (tembuf, " %d", (int) XFASTINT (tem)); |
| 578 | 1009 write_string (tembuf, -1); |
| 1010 } | |
| 1011 } | |
| 1012 | |
| 1013 if (EQ (symbol, Qsignal) || EQ (symbol, Qexit)) | |
| 1014 remove_process (proc); | |
| 1015 | |
| 1016 Findent_to (make_number (22), minspace); | |
| 1017 if (NILP (p->buffer)) | |
| 1018 insert_string ("(none)"); | |
| 1019 else if (NILP (XBUFFER (p->buffer)->name)) | |
| 1020 insert_string ("(Killed)"); | |
| 1021 else | |
| 1022 Finsert (1, &XBUFFER (p->buffer)->name); | |
| 1023 | |
| 1024 Findent_to (make_number (37), minspace); | |
| 1025 | |
|
9697
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1026 if (STRINGP (p->tty_name)) |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1027 Finsert (1, &p->tty_name); |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1028 else |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1029 insert_string ("(none)"); |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1030 |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1031 Findent_to (make_number (49), minspace); |
|
328b8bc31f73
(list_processes_1): Print tty name.
Karl Heuer <kwzh@gnu.org>
parents:
9686
diff
changeset
|
1032 |
| 578 | 1033 if (NETCONN_P (proc)) |
| 1034 { | |
| 1035 sprintf (tembuf, "(network stream connection to %s)\n", | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
1036 XSTRING (XCAR (p->childp))->data); |
| 578 | 1037 insert_string (tembuf); |
| 1038 } | |
| 1039 else | |
| 1040 { | |
| 1041 tem = p->command; | |
| 1042 while (1) | |
| 1043 { | |
| 1044 tem1 = Fcar (tem); | |
| 1045 Finsert (1, &tem1); | |
| 1046 tem = Fcdr (tem); | |
| 1047 if (NILP (tem)) | |
| 1048 break; | |
| 1049 insert_string (" "); | |
| 1050 } | |
| 1051 insert_string ("\n"); | |
| 1052 } | |
| 1053 } | |
| 1054 return Qnil; | |
| 1055 } | |
| 1056 | |
| 1057 DEFUN ("list-processes", Flist_processes, Slist_processes, 0, 0, "", | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1058 doc: /* Display a list of all processes. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1059 Any process listed as exited or signaled is actually eliminated |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1060 after the listing is made. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1061 () |
| 578 | 1062 { |
| 1063 internal_with_output_to_temp_buffer ("*Process List*", | |
| 1064 list_processes_1, Qnil); | |
| 1065 return Qnil; | |
| 1066 } | |
| 1067 | |
| 1068 DEFUN ("process-list", Fprocess_list, Sprocess_list, 0, 0, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1069 doc: /* Return a list of all processes. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1070 () |
| 578 | 1071 { |
| 1072 return Fmapcar (Qcdr, Vprocess_alist); | |
| 1073 } | |
| 1074 | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1075 /* Starting asynchronous inferior processes. */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1076 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1077 static Lisp_Object start_process_unwind (); |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1078 |
| 578 | 1079 DEFUN ("start-process", Fstart_process, Sstart_process, 3, MANY, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1080 doc: /* Start a program in a subprocess. Return the process object for it. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1081 NAME is name for process. It is modified if necessary to make it unique. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1082 BUFFER is the buffer or (buffer-name) to associate with the process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1083 Process output goes at end of that buffer, unless you specify |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1084 an output stream or filter function to handle the output. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1085 BUFFER may be also nil, meaning that this process is not associated |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1086 with any buffer. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1087 Third arg is program file name. It is searched for in PATH. |
|
40641
d94fc1022312
(Fstart_process): Add usage to doc-string.
Pavel Jan?k <Pavel@Janik.cz>
parents:
40231
diff
changeset
|
1088 Remaining arguments are strings to give program as arguments. |
|
d94fc1022312
(Fstart_process): Add usage to doc-string.
Pavel Jan?k <Pavel@Janik.cz>
parents:
40231
diff
changeset
|
1089 usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1090 (nargs, args) |
| 578 | 1091 int nargs; |
| 1092 register Lisp_Object *args; | |
| 1093 { | |
|
1683
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1094 Lisp_Object buffer, name, program, proc, current_dir, tem; |
| 578 | 1095 #ifdef VMS |
| 1096 register unsigned char *new_argv; | |
| 1097 int len; | |
| 1098 #else | |
| 1099 register unsigned char **new_argv; | |
| 1100 #endif | |
| 1101 register int i; | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1102 int count = specpdl_ptr - specpdl; |
| 578 | 1103 |
| 1104 buffer = args[1]; | |
| 1105 if (!NILP (buffer)) | |
| 1106 buffer = Fget_buffer_create (buffer); | |
| 1107 | |
|
1683
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1108 /* Make sure that the child will be able to chdir to the current |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1109 buffer's current directory, or its unhandled equivalent. We |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1110 can't just have the child check for an error when it does the |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1111 chdir, since it's in a vfork. |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1112 |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1113 We have to GCPRO around this because Fexpand_file_name and |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1114 Funhandled_file_name_directory might call a file name handling |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1115 function. The argument list is protected by the caller, so all |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1116 we really have to worry about is buffer. */ |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1117 { |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1118 struct gcpro gcpro1, gcpro2; |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1119 |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1120 current_dir = current_buffer->directory; |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1121 |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1122 GCPRO2 (buffer, current_dir); |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1123 |
|
10744
54a76e0b97ec
(Fstart_process): Make process marker point into proc buf.
Richard M. Stallman <rms@gnu.org>
parents:
10548
diff
changeset
|
1124 current_dir |
|
54a76e0b97ec
(Fstart_process): Make process marker point into proc buf.
Richard M. Stallman <rms@gnu.org>
parents:
10548
diff
changeset
|
1125 = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir), |
|
54a76e0b97ec
(Fstart_process): Make process marker point into proc buf.
Richard M. Stallman <rms@gnu.org>
parents:
10548
diff
changeset
|
1126 Qnil); |
|
1683
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1127 if (NILP (Ffile_accessible_directory_p (current_dir))) |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1128 report_file_error ("Setting current directory", |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1129 Fcons (current_buffer->directory, Qnil)); |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1130 |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1131 UNGCPRO; |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1132 } |
|
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1133 |
| 578 | 1134 name = args[0]; |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1135 CHECK_STRING (name); |
| 578 | 1136 |
| 1137 program = args[2]; | |
| 1138 | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1139 CHECK_STRING (program); |
| 578 | 1140 |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1141 proc = make_process (name); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1142 /* If an error occurs and we can't start the process, we want to |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1143 remove it from the process list. This means that each error |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1144 check in create_process doesn't need to call remove_process |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1145 itself; it's all taken care of here. */ |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1146 record_unwind_protect (start_process_unwind, proc); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1147 |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1148 XPROCESS (proc)->childp = Qt; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1149 XPROCESS (proc)->command_channel_p = Qnil; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1150 XPROCESS (proc)->buffer = buffer; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1151 XPROCESS (proc)->sentinel = Qnil; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1152 XPROCESS (proc)->filter = Qnil; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1153 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1154 |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1155 /* Make the process marker point into the process buffer (if any). */ |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1156 if (!NILP (buffer)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1157 set_marker_both (XPROCESS (proc)->mark, buffer, |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1158 BUF_ZV (XBUFFER (buffer)), |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1159 BUF_ZV_BYTE (XBUFFER (buffer))); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1160 |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1161 { |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1162 /* Decide coding systems for communicating with the process. Here |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1163 we don't setup the structure coding_system nor pay attention to |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1164 unibyte mode. They are done in create_process. */ |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1165 |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1166 /* Qt denotes we have not yet called Ffind_operation_coding_system. */ |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1167 Lisp_Object coding_systems = Qt; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1168 Lisp_Object val, *args2; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1169 struct gcpro gcpro1, gcpro2; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1170 |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1171 val = Vcoding_system_for_read; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1172 if (NILP (val)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1173 { |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1174 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1175 args2[0] = Qstart_process; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1176 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1177 GCPRO2 (proc, current_dir); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1178 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1179 UNGCPRO; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1180 if (CONSP (coding_systems)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1181 val = XCAR (coding_systems); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1182 else if (CONSP (Vdefault_process_coding_system)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1183 val = XCAR (Vdefault_process_coding_system); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1184 } |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1185 XPROCESS (proc)->decode_coding_system = val; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1186 |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1187 val = Vcoding_system_for_write; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1188 if (NILP (val)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1189 { |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1190 if (EQ (coding_systems, Qt)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1191 { |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1192 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof args2); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1193 args2[0] = Qstart_process; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1194 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1195 GCPRO2 (proc, current_dir); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1196 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1197 UNGCPRO; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1198 } |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1199 if (CONSP (coding_systems)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1200 val = XCDR (coding_systems); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1201 else if (CONSP (Vdefault_process_coding_system)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1202 val = XCDR (Vdefault_process_coding_system); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1203 } |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1204 XPROCESS (proc)->encode_coding_system = val; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1205 } |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1206 |
| 578 | 1207 #ifdef VMS |
| 1208 /* Make a one member argv with all args concatenated | |
| 1209 together separated by a blank. */ | |
|
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21177
diff
changeset
|
1210 len = STRING_BYTES (XSTRING (program)) + 2; |
| 578 | 1211 for (i = 3; i < nargs; i++) |
| 1212 { | |
| 1213 tem = args[i]; | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1214 CHECK_STRING (tem); |
|
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21177
diff
changeset
|
1215 len += STRING_BYTES (XSTRING (tem)) + 1; /* count the blank */ |
| 578 | 1216 } |
| 1217 new_argv = (unsigned char *) alloca (len); | |
| 1218 strcpy (new_argv, XSTRING (program)->data); | |
| 1219 for (i = 3; i < nargs; i++) | |
| 1220 { | |
| 1221 tem = args[i]; | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1222 CHECK_STRING (tem); |
| 578 | 1223 strcat (new_argv, " "); |
| 1224 strcat (new_argv, XSTRING (tem)->data); | |
| 1225 } | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1226 /* Need to add code here to check for program existence on VMS */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1227 |
| 578 | 1228 #else /* not VMS */ |
| 1229 new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); | |
| 1230 | |
|
6390
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1231 /* If program file name is not absolute, search our path for it */ |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1232 if (!IS_DIRECTORY_SEP (XSTRING (program)->data[0]) |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1233 && !(XSTRING (program)->size > 1 |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1234 && IS_DEVICE_SEP (XSTRING (program)->data[1]))) |
|
6390
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1235 { |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1236 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1237 |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1238 tem = Qnil; |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1239 GCPRO4 (name, program, buffer, current_dir); |
|
39812
66e0816837a8
Update calls to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39429
diff
changeset
|
1240 openp (Vexec_path, program, Vexec_suffixes, &tem, 1); |
|
6390
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1241 UNGCPRO; |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1242 if (NILP (tem)) |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1243 report_file_error ("Searching for program", Fcons (program, Qnil)); |
|
12648
98aba238cf62
(Fstart_process): Don't expand the file name before trying openp.
Richard M. Stallman <rms@gnu.org>
parents:
12541
diff
changeset
|
1244 tem = Fexpand_file_name (tem, Qnil); |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1245 tem = ENCODE_FILE (tem); |
|
6390
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1246 new_argv[0] = XSTRING (tem)->data; |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1247 } |
|
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1248 else |
|
12491
4ad7be34ece1
(Fstart_process): Expand PROGRAM.
Richard M. Stallman <rms@gnu.org>
parents:
12378
diff
changeset
|
1249 { |
|
4ad7be34ece1
(Fstart_process): Expand PROGRAM.
Richard M. Stallman <rms@gnu.org>
parents:
12378
diff
changeset
|
1250 if (!NILP (Ffile_directory_p (program))) |
|
4ad7be34ece1
(Fstart_process): Expand PROGRAM.
Richard M. Stallman <rms@gnu.org>
parents:
12378
diff
changeset
|
1251 error ("Specified program for new process is a directory"); |
|
4ad7be34ece1
(Fstart_process): Expand PROGRAM.
Richard M. Stallman <rms@gnu.org>
parents:
12378
diff
changeset
|
1252 |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1253 tem = ENCODE_FILE (program); |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1254 new_argv[0] = XSTRING (tem)->data; |
|
12491
4ad7be34ece1
(Fstart_process): Expand PROGRAM.
Richard M. Stallman <rms@gnu.org>
parents:
12378
diff
changeset
|
1255 } |
|
6390
9f8ce71435de
(Fstart_process): GCPRO some things.
Karl Heuer <kwzh@gnu.org>
parents:
6345
diff
changeset
|
1256 |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1257 /* Here we encode arguments by the coding system used for sending |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1258 data to the process. We don't support using different coding |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1259 systems for encoding arguments and for encoding data sent to the |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1260 process. */ |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1261 |
| 578 | 1262 for (i = 3; i < nargs; i++) |
| 1263 { | |
| 1264 tem = args[i]; | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1265 CHECK_STRING (tem); |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1266 if (STRING_MULTIBYTE (tem)) |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1267 tem = (code_convert_string_norecord |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
1268 (tem, XPROCESS (proc)->encode_coding_system, 1)); |
| 578 | 1269 new_argv[i - 2] = XSTRING (tem)->data; |
| 1270 } | |
| 1271 new_argv[i - 2] = 0; | |
| 1272 #endif /* not VMS */ | |
| 1273 | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
1274 XPROCESS (proc)->decoding_buf = make_uninit_string (0); |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1275 XPROCESS (proc)->decoding_carryover = make_number (0); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
1276 XPROCESS (proc)->encoding_buf = make_uninit_string (0); |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
1277 XPROCESS (proc)->encoding_carryover = make_number (0); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
1278 |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
1279 XPROCESS (proc)->inherit_coding_system_flag |
|
21848
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
1280 = (NILP (buffer) || !inherit_process_coding_system |
|
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
1281 ? Qnil : Qt); |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
1282 |
|
20382
dbad9367d232
(create_process, deactivate_process, close_process_descs):
Andreas Schwab <schwab@suse.de>
parents:
20225
diff
changeset
|
1283 create_process (proc, (char **) new_argv, current_dir); |
| 578 | 1284 |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1285 return unbind_to (count, proc); |
| 578 | 1286 } |
| 1287 | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1288 /* This function is the unwind_protect form for Fstart_process. If |
| 14036 | 1289 PROC doesn't have its pid set, then we know someone has signaled |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1290 an error and the process wasn't started successfully, so we should |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1291 remove it from the process list. */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1292 static Lisp_Object |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1293 start_process_unwind (proc) |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1294 Lisp_Object proc; |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1295 { |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
1296 if (!PROCESSP (proc)) |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1297 abort (); |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1298 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1299 /* Was PROC started successfully? */ |
|
3685
47d7fda8a609
(start_process_unwind): Use XINT.
Richard M. Stallman <rms@gnu.org>
parents:
3666
diff
changeset
|
1300 if (XINT (XPROCESS (proc)->pid) <= 0) |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1301 remove_process (proc); |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1302 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1303 return Qnil; |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1304 } |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
1305 |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1306 void |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1307 create_process_1 (timer) |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1308 struct atimer *timer; |
| 578 | 1309 { |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1310 /* Nothing to do. */ |
| 578 | 1311 } |
| 1312 | |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1313 |
| 578 | 1314 #if 0 /* This doesn't work; see the note before sigchld_handler. */ |
| 1315 #ifdef USG | |
| 1316 #ifdef SIGCHLD | |
| 1317 /* Mimic blocking of signals on system V, which doesn't really have it. */ | |
| 1318 | |
| 1319 /* Nonzero means we got a SIGCHLD when it was supposed to be blocked. */ | |
| 1320 int sigchld_deferred; | |
| 1321 | |
| 1322 SIGTYPE | |
| 1323 create_process_sigchld () | |
| 1324 { | |
| 1325 signal (SIGCHLD, create_process_sigchld); | |
| 1326 | |
| 1327 sigchld_deferred = 1; | |
| 1328 } | |
| 1329 #endif | |
| 1330 #endif | |
| 1331 #endif | |
| 1332 | |
| 1333 #ifndef VMS /* VMS version of this function is in vmsproc.c. */ | |
|
20382
dbad9367d232
(create_process, deactivate_process, close_process_descs):
Andreas Schwab <schwab@suse.de>
parents:
20225
diff
changeset
|
1334 void |
|
1683
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1335 create_process (process, new_argv, current_dir) |
| 578 | 1336 Lisp_Object process; |
| 1337 char **new_argv; | |
|
1683
a0a41de51400
Give subprocess creation a way to find a valid current directory
Jim Blandy <jimb@redhat.com>
parents:
1655
diff
changeset
|
1338 Lisp_Object current_dir; |
| 578 | 1339 { |
|
11926
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
1340 int pid, inchannel, outchannel; |
| 578 | 1341 int sv[2]; |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1342 #ifdef POSIX_SIGNALS |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1343 sigset_t procmask; |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1344 sigset_t blocked; |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1345 struct sigaction sigint_action; |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1346 struct sigaction sigquit_action; |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1347 #ifdef AIX |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1348 struct sigaction sighup_action; |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1349 #endif |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1350 #else /* !POSIX_SIGNALS */ |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
1351 #if 0 |
| 578 | 1352 #ifdef SIGCHLD |
| 1353 SIGTYPE (*sigchld)(); | |
| 1354 #endif | |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
1355 #endif /* 0 */ |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1356 #endif /* !POSIX_SIGNALS */ |
|
11926
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
1357 /* Use volatile to protect variables from being clobbered by longjmp. */ |
|
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
1358 volatile int forkin, forkout; |
|
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
1359 volatile int pty_flag = 0; |
|
31099
0fe5afca71e4
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30582
diff
changeset
|
1360 #ifndef USE_CRT_DLL |
| 578 | 1361 extern char **environ; |
|
31099
0fe5afca71e4
Include keyboard.h before frame.h.
Andrew Innes <andrewi@gnu.org>
parents:
30582
diff
changeset
|
1362 #endif |
| 578 | 1363 |
| 1364 inchannel = outchannel = -1; | |
| 1365 | |
| 1366 #ifdef HAVE_PTYS | |
|
7748
9a9c8372af80
(create_process): Get a pty for any non-nil Vprocess_connection_type value.
Richard M. Stallman <rms@gnu.org>
parents:
7605
diff
changeset
|
1367 if (!NILP (Vprocess_connection_type)) |
| 578 | 1368 outchannel = inchannel = allocate_pty (); |
| 1369 | |
| 1370 if (inchannel >= 0) | |
| 1371 { | |
| 1372 #ifndef USG | |
| 1373 /* On USG systems it does not work to open the pty's tty here | |
| 1374 and then close and reopen it in the child. */ | |
| 1375 #ifdef O_NOCTTY | |
| 1376 /* Don't let this terminal become our controlling terminal | |
| 1377 (in case we don't have one). */ | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1378 forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| 578 | 1379 #else |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1380 forkout = forkin = emacs_open (pty_name, O_RDWR, 0); |
| 578 | 1381 #endif |
| 1382 if (forkin < 0) | |
| 1383 report_file_error ("Opening pty", Qnil); | |
| 1384 #else | |
| 1385 forkin = forkout = -1; | |
| 1386 #endif /* not USG */ | |
| 1387 pty_flag = 1; | |
| 1388 } | |
| 1389 else | |
| 1390 #endif /* HAVE_PTYS */ | |
| 1391 #ifdef SKTPAIR | |
| 1392 { | |
| 1393 if (socketpair (AF_UNIX, SOCK_STREAM, 0, sv) < 0) | |
| 1394 report_file_error ("Opening socketpair", Qnil); | |
| 1395 outchannel = inchannel = sv[0]; | |
| 1396 forkout = forkin = sv[1]; | |
| 1397 } | |
| 1398 #else /* not SKTPAIR */ | |
| 1399 { | |
|
25129
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1400 int tem; |
|
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1401 tem = pipe (sv); |
|
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1402 if (tem < 0) |
|
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1403 report_file_error ("Creating pipe", Qnil); |
| 578 | 1404 inchannel = sv[0]; |
| 1405 forkout = sv[1]; | |
|
25129
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1406 tem = pipe (sv); |
|
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1407 if (tem < 0) |
|
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1408 { |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1409 emacs_close (inchannel); |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1410 emacs_close (forkout); |
|
25129
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1411 report_file_error ("Creating pipe", Qnil); |
|
4f3c8f1cec96
(create_process): Detect failure of `pipe'.
Karl Heuer <kwzh@gnu.org>
parents:
25009
diff
changeset
|
1412 } |
| 578 | 1413 outchannel = sv[1]; |
| 1414 forkin = sv[0]; | |
| 1415 } | |
| 1416 #endif /* not SKTPAIR */ | |
| 1417 | |
| 1418 #if 0 | |
| 1419 /* Replaced by close_process_descs */ | |
| 1420 set_exclusive_use (inchannel); | |
| 1421 set_exclusive_use (outchannel); | |
| 1422 #endif | |
| 1423 | |
| 1424 /* Stride people say it's a mystery why this is needed | |
| 1425 as well as the O_NDELAY, but that it fails without this. */ | |
| 1426 #if defined (STRIDE) || (defined (pfa) && defined (HAVE_PTYS)) | |
| 1427 { | |
| 1428 int one = 1; | |
| 1429 ioctl (inchannel, FIONBIO, &one); | |
| 1430 } | |
| 1431 #endif | |
| 1432 | |
| 1433 #ifdef O_NONBLOCK | |
| 1434 fcntl (inchannel, F_SETFL, O_NONBLOCK); | |
|
14405
4aa693528ee3
(create_process): Set outchannel to be non-blocking.
Richard M. Stallman <rms@gnu.org>
parents:
14404
diff
changeset
|
1435 fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 578 | 1436 #else |
| 1437 #ifdef O_NDELAY | |
| 1438 fcntl (inchannel, F_SETFL, O_NDELAY); | |
|
14405
4aa693528ee3
(create_process): Set outchannel to be non-blocking.
Richard M. Stallman <rms@gnu.org>
parents:
14404
diff
changeset
|
1439 fcntl (outchannel, F_SETFL, O_NDELAY); |
| 578 | 1440 #endif |
| 1441 #endif | |
| 1442 | |
| 1443 /* Record this as an active process, with its channels. | |
| 1444 As a result, child_setup will close Emacs's side of the pipes. */ | |
| 1445 chan_process[inchannel] = process; | |
|
9277
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
1446 XSETINT (XPROCESS (process)->infd, inchannel); |
|
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
1447 XSETINT (XPROCESS (process)->outfd, outchannel); |
| 578 | 1448 /* Record the tty descriptor used in the subprocess. */ |
| 1449 if (forkin < 0) | |
| 1450 XPROCESS (process)->subtty = Qnil; | |
| 1451 else | |
|
9318
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
1452 XSETFASTINT (XPROCESS (process)->subtty, forkin); |
| 578 | 1453 XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil); |
| 1454 XPROCESS (process)->status = Qrun; | |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
1455 if (!proc_decode_coding_system[inchannel]) |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
1456 proc_decode_coding_system[inchannel] |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
1457 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
1458 setup_coding_system (XPROCESS (process)->decode_coding_system, |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
1459 proc_decode_coding_system[inchannel]); |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
1460 if (!proc_encode_coding_system[outchannel]) |
| 22848 | 1461 proc_encode_coding_system[outchannel] |
| 1462 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
1463 setup_coding_system (XPROCESS (process)->encode_coding_system, |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
1464 proc_encode_coding_system[outchannel]); |
| 578 | 1465 |
| 1466 /* Delay interrupts until we have a chance to store | |
| 1467 the new fork's pid in its process structure */ | |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1468 #ifdef POSIX_SIGNALS |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1469 sigemptyset (&blocked); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1470 #ifdef SIGCHLD |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1471 sigaddset (&blocked, SIGCHLD); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1472 #endif |
|
41856
0028402ed7d1
(create_process): Use HAVE_WORKING_VFORK, not HAVE_VFORK.
Paul Eggert <eggert@twinsun.com>
parents:
40656
diff
changeset
|
1473 #ifdef HAVE_WORKING_VFORK |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1474 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal', |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1475 this sets the parent's signal handlers as well as the child's. |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1476 So delay all interrupts whose handlers the child might munge, |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1477 and record the current handlers so they can be restored later. */ |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1478 sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action ); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1479 sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1480 #ifdef AIX |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1481 sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action ); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1482 #endif |
|
41856
0028402ed7d1
(create_process): Use HAVE_WORKING_VFORK, not HAVE_VFORK.
Paul Eggert <eggert@twinsun.com>
parents:
40656
diff
changeset
|
1483 #endif /* HAVE_WORKING_VFORK */ |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1484 sigprocmask (SIG_BLOCK, &blocked, &procmask); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1485 #else /* !POSIX_SIGNALS */ |
| 578 | 1486 #ifdef SIGCHLD |
| 1487 #ifdef BSD4_1 | |
| 1488 sighold (SIGCHLD); | |
| 1489 #else /* not BSD4_1 */ | |
|
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16206
diff
changeset
|
1490 #if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX) |
| 578 | 1491 sigsetmask (sigmask (SIGCHLD)); |
| 1492 #else /* ordinary USG */ | |
| 1493 #if 0 | |
| 1494 sigchld_deferred = 0; | |
| 1495 sigchld = signal (SIGCHLD, create_process_sigchld); | |
| 1496 #endif | |
| 1497 #endif /* ordinary USG */ | |
| 1498 #endif /* not BSD4_1 */ | |
| 1499 #endif /* SIGCHLD */ | |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1500 #endif /* !POSIX_SIGNALS */ |
| 578 | 1501 |
|
7893
e54617027a47
(create_process): Set input_wait_mask before forking.
Karl Heuer <kwzh@gnu.org>
parents:
7884
diff
changeset
|
1502 FD_SET (inchannel, &input_wait_mask); |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
1503 FD_SET (inchannel, &non_keyboard_wait_mask); |
|
7893
e54617027a47
(create_process): Set input_wait_mask before forking.
Karl Heuer <kwzh@gnu.org>
parents:
7884
diff
changeset
|
1504 if (inchannel > max_process_desc) |
|
e54617027a47
(create_process): Set input_wait_mask before forking.
Karl Heuer <kwzh@gnu.org>
parents:
7884
diff
changeset
|
1505 max_process_desc = inchannel; |
|
e54617027a47
(create_process): Set input_wait_mask before forking.
Karl Heuer <kwzh@gnu.org>
parents:
7884
diff
changeset
|
1506 |
| 578 | 1507 /* Until we store the proper pid, enable sigchld_handler |
| 1508 to recognize an unknown pid as standing for this process. | |
| 1509 It is very important not to let this `marker' value stay | |
| 1510 in the table after this function has returned; if it does | |
| 1511 it might cause call-process to hang and subsequent asynchronous | |
| 1512 processes to get their return values scrambled. */ | |
| 1513 XSETINT (XPROCESS (process)->pid, -1); | |
| 1514 | |
| 16780 | 1515 BLOCK_INPUT; |
| 1516 | |
| 578 | 1517 { |
| 1518 /* child_setup must clobber environ on systems with true vfork. | |
| 1519 Protect it from permanent change. */ | |
| 1520 char **save_environ = environ; | |
| 1521 | |
|
21049
01e626b0a624
(Vdefault_file_name_coding_system): Extern it.
Kenichi Handa <handa@m17n.org>
parents:
20715
diff
changeset
|
1522 current_dir = ENCODE_FILE (current_dir); |
|
19837
3bee81323f73
(create_process): Encode the new current dir.
Richard M. Stallman <rms@gnu.org>
parents:
19642
diff
changeset
|
1523 |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1524 #ifndef WINDOWSNT |
| 578 | 1525 pid = vfork (); |
| 1526 if (pid == 0) | |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1527 #endif /* not WINDOWSNT */ |
| 578 | 1528 { |
| 1529 int xforkin = forkin; | |
| 1530 int xforkout = forkout; | |
| 1531 | |
| 1532 #if 0 /* This was probably a mistake--it duplicates code later on, | |
| 1533 but fails to handle all the cases. */ | |
| 1534 /* Make sure SIGCHLD is not blocked in the child. */ | |
| 1535 sigsetmask (SIGEMPTYMASK); | |
| 1536 #endif | |
| 1537 | |
| 1538 /* Make the pty be the controlling terminal of the process. */ | |
| 1539 #ifdef HAVE_PTYS | |
| 1540 /* First, disconnect its current controlling terminal. */ | |
| 1541 #ifdef HAVE_SETSID | |
|
7266
f87808bd90e9
(create_process): Undo April 19 setsid change.
Richard M. Stallman <rms@gnu.org>
parents:
7238
diff
changeset
|
1542 /* We tried doing setsid only if pty_flag, but it caused |
|
f87808bd90e9
(create_process): Undo April 19 setsid change.
Richard M. Stallman <rms@gnu.org>
parents:
7238
diff
changeset
|
1543 process_set_signal to fail on SGI when using a pipe. */ |
|
f87808bd90e9
(create_process): Undo April 19 setsid change.
Richard M. Stallman <rms@gnu.org>
parents:
7238
diff
changeset
|
1544 setsid (); |
|
1030
9934251d8219
(WCOREDUMP): Define only if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
1012
diff
changeset
|
1545 /* Make the pty's terminal the controlling terminal. */ |
|
3023
cfd999700613
(create_process): Ignore retval from TIOCSTTY.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
1546 if (pty_flag) |
|
6975
b7411e378b65
(create_process): Call setsid only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
6947
diff
changeset
|
1547 { |
|
b7411e378b65
(create_process): Call setsid only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
6947
diff
changeset
|
1548 #ifdef TIOCSCTTY |
|
b7411e378b65
(create_process): Call setsid only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
6947
diff
changeset
|
1549 /* We ignore the return value |
|
b7411e378b65
(create_process): Call setsid only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
6947
diff
changeset
|
1550 because faith@cs.unc.edu says that is necessary on Linux. */ |
|
b7411e378b65
(create_process): Call setsid only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
6947
diff
changeset
|
1551 ioctl (xforkin, TIOCSCTTY, 0); |
|
1030
9934251d8219
(WCOREDUMP): Define only if not defined.
Richard M. Stallman <rms@gnu.org>
parents:
1012
diff
changeset
|
1552 #endif |
|
6975
b7411e378b65
(create_process): Call setsid only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
6947
diff
changeset
|
1553 } |
| 578 | 1554 #else /* not HAVE_SETSID */ |
|
5181
31874690939f
(create_process): Do setpgrp for USG regardless of IRIX.
Richard M. Stallman <rms@gnu.org>
parents:
5161
diff
changeset
|
1555 #ifdef USG |
|
5347
21bffe027a7d
(create_process) [NTTYDISC]: Set the tty line discipline.
Richard M. Stallman <rms@gnu.org>
parents:
5332
diff
changeset
|
1556 /* It's very important to call setpgrp here and no time |
| 578 | 1557 afterwards. Otherwise, we lose our controlling tty which |
| 1558 is set when we open the pty. */ | |
| 1559 setpgrp (); | |
| 1560 #endif /* USG */ | |
| 1561 #endif /* not HAVE_SETSID */ | |
|
7116
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1562 #if defined (HAVE_TERMIOS) && defined (LDISC1) |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1563 if (pty_flag && xforkin >= 0) |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1564 { |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1565 struct termios t; |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1566 tcgetattr (xforkin, &t); |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1567 t.c_lflag = LDISC1; |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1568 if (tcsetattr (xforkin, TCSANOW, &t) < 0) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1569 emacs_write (1, "create_process/tcsetattr LDISC1 failed\n", 39); |
|
7116
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1570 } |
|
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1571 #else |
|
6947
c5f990fad6bb
(create_process): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents:
6928
diff
changeset
|
1572 #if defined (NTTYDISC) && defined (TIOCSETD) |
|
6393
7de1d288460e
(create_process): Skip the ioctl if fd is -1.
Karl Heuer <kwzh@gnu.org>
parents:
6390
diff
changeset
|
1573 if (pty_flag && xforkin >= 0) |
|
5548
36d2fd17f833
(create_process): Set line discipline only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
5543
diff
changeset
|
1574 { |
|
36d2fd17f833
(create_process): Set line discipline only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
5543
diff
changeset
|
1575 /* Use new line discipline. */ |
|
36d2fd17f833
(create_process): Set line discipline only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
5543
diff
changeset
|
1576 int ldisc = NTTYDISC; |
|
7605
53186c2698e5
(create_process): Don't complain about error from TIOCSETD.
Richard M. Stallman <rms@gnu.org>
parents:
7486
diff
changeset
|
1577 ioctl (xforkin, TIOCSETD, &ldisc); |
|
5548
36d2fd17f833
(create_process): Set line discipline only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
5543
diff
changeset
|
1578 } |
|
5347
21bffe027a7d
(create_process) [NTTYDISC]: Set the tty line discipline.
Richard M. Stallman <rms@gnu.org>
parents:
5332
diff
changeset
|
1579 #endif |
|
7116
d35b11eed89f
(create_process) [HAVE_TERMIOS && LDISC1]: Use tcsetattr.
Karl Heuer <kwzh@gnu.org>
parents:
7059
diff
changeset
|
1580 #endif |
| 578 | 1581 #ifdef TIOCNOTTY |
| 1582 /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you | |
| 1583 can do TIOCSPGRP only to the process's controlling tty. */ | |
| 1584 if (pty_flag) | |
| 1585 { | |
| 1586 /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? | |
| 1587 I can't test it since I don't have 4.3. */ | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1588 int j = emacs_open ("/dev/tty", O_RDWR, 0); |
| 578 | 1589 ioctl (j, TIOCNOTTY, 0); |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1590 emacs_close (j); |
|
3826
647bef18618f
Changes for Irix 4.0, tested this time:
Jim Blandy <jimb@redhat.com>
parents:
3810
diff
changeset
|
1591 #ifndef USG |
| 578 | 1592 /* In order to get a controlling terminal on some versions |
| 1593 of BSD, it is necessary to put the process in pgrp 0 | |
| 1594 before it opens the terminal. */ | |
|
16127
8d6d35b486c0
(create_process): Test HAVE_SETPGID for using setpgid.
Richard M. Stallman <rms@gnu.org>
parents:
16116
diff
changeset
|
1595 #ifdef HAVE_SETPGID |
|
9882
ccc5562a7194
(create_process) [OSF1]: Use setpgid, not setpgrp.
Richard M. Stallman <rms@gnu.org>
parents:
9793
diff
changeset
|
1596 setpgid (0, 0); |
|
ccc5562a7194
(create_process) [OSF1]: Use setpgid, not setpgrp.
Richard M. Stallman <rms@gnu.org>
parents:
9793
diff
changeset
|
1597 #else |
| 578 | 1598 setpgrp (0, 0); |
| 1599 #endif | |
|
9882
ccc5562a7194
(create_process) [OSF1]: Use setpgid, not setpgrp.
Richard M. Stallman <rms@gnu.org>
parents:
9793
diff
changeset
|
1600 #endif |
| 578 | 1601 } |
| 1602 #endif /* TIOCNOTTY */ | |
| 1603 | |
|
16076
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1604 #if !defined (RTU) && !defined (UNIPLUS) && !defined (DONT_REOPEN_PTY) |
| 578 | 1605 /*** There is a suggestion that this ought to be a |
|
16076
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1606 conditional on TIOCSPGRP, |
|
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1607 or !(defined (HAVE_SETSID) && defined (TIOCSCTTY)). |
|
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1608 Trying the latter gave the wrong results on Debian GNU/Linux 1.1; |
|
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1609 that system does seem to need this code, even though |
|
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1610 both HAVE_SETSID and TIOCSCTTY are defined. */ |
| 578 | 1611 /* Now close the pty (if we had it open) and reopen it. |
| 1612 This makes the pty the controlling terminal of the subprocess. */ | |
| 1613 if (pty_flag) | |
| 1614 { | |
|
5240
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1615 #ifdef SET_CHILD_PTY_PGRP |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1616 int pgrp = getpid (); |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1617 #endif |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1618 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1619 /* I wonder if emacs_close (emacs_open (pty_name, ...)) |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1620 would work? */ |
| 578 | 1621 if (xforkin >= 0) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1622 emacs_close (xforkin); |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1623 xforkout = xforkin = emacs_open (pty_name, O_RDWR, 0); |
| 578 | 1624 |
|
11514
321726163a65
(create_process): Don't abort if can't reopen
Richard M. Stallman <rms@gnu.org>
parents:
11376
diff
changeset
|
1625 if (xforkin < 0) |
|
321726163a65
(create_process): Don't abort if can't reopen
Richard M. Stallman <rms@gnu.org>
parents:
11376
diff
changeset
|
1626 { |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1627 emacs_write (1, "Couldn't open the pty terminal ", 31); |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1628 emacs_write (1, pty_name, strlen (pty_name)); |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1629 emacs_write (1, "\n", 1); |
|
11514
321726163a65
(create_process): Don't abort if can't reopen
Richard M. Stallman <rms@gnu.org>
parents:
11376
diff
changeset
|
1630 _exit (1); |
|
321726163a65
(create_process): Don't abort if can't reopen
Richard M. Stallman <rms@gnu.org>
parents:
11376
diff
changeset
|
1631 } |
|
321726163a65
(create_process): Don't abort if can't reopen
Richard M. Stallman <rms@gnu.org>
parents:
11376
diff
changeset
|
1632 |
|
5240
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1633 #ifdef SET_CHILD_PTY_PGRP |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1634 ioctl (xforkin, TIOCSPGRP, &pgrp); |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1635 ioctl (xforkout, TIOCSPGRP, &pgrp); |
|
eed870591987
(Fprocess_status): Use get_process, not Fget_process.
Richard M. Stallman <rms@gnu.org>
parents:
5239
diff
changeset
|
1636 #endif |
| 578 | 1637 } |
|
16076
5d1e0290bbd0
(create_process): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
16058
diff
changeset
|
1638 #endif /* not UNIPLUS and not RTU and not DONT_REOPEN_PTY */ |
|
15368
6229fb866493
(create_process): Add DONT_OPEN_PTY conditional.
Richard M. Stallman <rms@gnu.org>
parents:
15355
diff
changeset
|
1639 |
| 578 | 1640 #ifdef SETUP_SLAVE_PTY |
|
7058
1855e568a9b8
(create_process): Use SETUP_SLAVE_PTY only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
7044
diff
changeset
|
1641 if (pty_flag) |
|
1855e568a9b8
(create_process): Use SETUP_SLAVE_PTY only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
7044
diff
changeset
|
1642 { |
|
1855e568a9b8
(create_process): Use SETUP_SLAVE_PTY only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
7044
diff
changeset
|
1643 SETUP_SLAVE_PTY; |
|
1855e568a9b8
(create_process): Use SETUP_SLAVE_PTY only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
7044
diff
changeset
|
1644 } |
| 578 | 1645 #endif /* SETUP_SLAVE_PTY */ |
| 1646 #ifdef AIX | |
| 1647 /* On AIX, we've disabled SIGHUP above once we start a child on a pty. | |
| 1648 Now reenable it in the child, so it will die when we want it to. */ | |
| 1649 if (pty_flag) | |
| 1650 signal (SIGHUP, SIG_DFL); | |
| 1651 #endif | |
| 1652 #endif /* HAVE_PTYS */ | |
| 1653 | |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1654 signal (SIGINT, SIG_DFL); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1655 signal (SIGQUIT, SIG_DFL); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1656 |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1657 /* Stop blocking signals in the child. */ |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1658 #ifdef POSIX_SIGNALS |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1659 sigprocmask (SIG_SETMASK, &procmask, 0); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1660 #else /* !POSIX_SIGNALS */ |
| 578 | 1661 #ifdef SIGCHLD |
| 1662 #ifdef BSD4_1 | |
| 1663 sigrelse (SIGCHLD); | |
| 1664 #else /* not BSD4_1 */ | |
|
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16206
diff
changeset
|
1665 #if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX) |
| 578 | 1666 sigsetmask (SIGEMPTYMASK); |
| 1667 #else /* ordinary USG */ | |
|
1207
af619d68a576
* process.c [SIGCHLD && !BSD && !UNIPLUS && !HPUX]
Jim Blandy <jimb@redhat.com>
parents:
1180
diff
changeset
|
1668 #if 0 |
| 578 | 1669 signal (SIGCHLD, sigchld); |
|
1207
af619d68a576
* process.c [SIGCHLD && !BSD && !UNIPLUS && !HPUX]
Jim Blandy <jimb@redhat.com>
parents:
1180
diff
changeset
|
1670 #endif |
| 578 | 1671 #endif /* ordinary USG */ |
| 1672 #endif /* not BSD4_1 */ | |
| 1673 #endif /* SIGCHLD */ | |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1674 #endif /* !POSIX_SIGNALS */ |
|
8390
ee13e8728666
(create_process): Set default handling for SIGINT, etc.
Richard M. Stallman <rms@gnu.org>
parents:
8354
diff
changeset
|
1675 |
|
7059
6a55de48ade5
(create_process): Use child_setup_tty only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
7058
diff
changeset
|
1676 if (pty_flag) |
|
6a55de48ade5
(create_process): Use child_setup_tty only if pty_flag.
Richard M. Stallman <rms@gnu.org>
parents:
7058
diff
changeset
|
1677 child_setup_tty (xforkout); |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1678 #ifdef WINDOWSNT |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1679 pid = child_setup (xforkin, xforkout, xforkout, |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1680 new_argv, 1, current_dir); |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1681 #else /* not WINDOWSNT */ |
| 578 | 1682 child_setup (xforkin, xforkout, xforkout, |
| 638 | 1683 new_argv, 1, current_dir); |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1684 #endif /* not WINDOWSNT */ |
| 578 | 1685 } |
| 1686 environ = save_environ; | |
| 1687 } | |
| 1688 | |
| 16780 | 1689 UNBLOCK_INPUT; |
| 1690 | |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1691 /* This runs in the Emacs process. */ |
| 578 | 1692 if (pid < 0) |
|
7157
3f4fc9d682b4
(create_process): If vfork fails, close forkin and forkout.
Richard M. Stallman <rms@gnu.org>
parents:
7116
diff
changeset
|
1693 { |
|
3f4fc9d682b4
(create_process): If vfork fails, close forkin and forkout.
Richard M. Stallman <rms@gnu.org>
parents:
7116
diff
changeset
|
1694 if (forkin >= 0) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1695 emacs_close (forkin); |
|
7157
3f4fc9d682b4
(create_process): If vfork fails, close forkin and forkout.
Richard M. Stallman <rms@gnu.org>
parents:
7116
diff
changeset
|
1696 if (forkin != forkout && forkout >= 0) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1697 emacs_close (forkout); |
|
7157
3f4fc9d682b4
(create_process): If vfork fails, close forkin and forkout.
Richard M. Stallman <rms@gnu.org>
parents:
7116
diff
changeset
|
1698 } |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1699 else |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1700 { |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1701 /* vfork succeeded. */ |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1702 XSETFASTINT (XPROCESS (process)->pid, pid); |
| 578 | 1703 |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1704 #ifdef WINDOWSNT |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1705 register_child (pid, inchannel); |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1706 #endif /* WINDOWSNT */ |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
1707 |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1708 /* If the subfork execv fails, and it exits, |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1709 this close hangs. I don't know why. |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1710 So have an interrupt jar it loose. */ |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1711 { |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1712 struct atimer *timer; |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1713 EMACS_TIME offset; |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1714 |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1715 stop_polling (); |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1716 EMACS_SET_SECS_USECS (offset, 1, 0); |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1717 timer = start_atimer (ATIMER_RELATIVE, offset, create_process_1, 0); |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1718 |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1719 XPROCESS (process)->subtty = Qnil; |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1720 if (forkin >= 0) |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1721 emacs_close (forkin); |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1722 |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1723 cancel_atimer (timer); |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1724 start_polling (); |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1725 } |
|
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
1726 |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1727 if (forkin != forkout && forkout >= 0) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
1728 emacs_close (forkout); |
| 578 | 1729 |
|
11609
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
1730 #ifdef HAVE_PTYS |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1731 if (pty_flag) |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1732 XPROCESS (process)->tty_name = build_string (pty_name); |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1733 else |
|
11609
3b2dacb1bfe9
(create_process): Don't reference pty_name if !HAVE_PTYS.
Karl Heuer <kwzh@gnu.org>
parents:
11514
diff
changeset
|
1734 #endif |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1735 XPROCESS (process)->tty_name = Qnil; |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1736 } |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1737 |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1738 /* Restore the signal state whether vfork succeeded or not. |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1739 (We will signal an error, below, if it failed.) */ |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1740 #ifdef POSIX_SIGNALS |
|
41856
0028402ed7d1
(create_process): Use HAVE_WORKING_VFORK, not HAVE_VFORK.
Paul Eggert <eggert@twinsun.com>
parents:
40656
diff
changeset
|
1741 #ifdef HAVE_WORKING_VFORK |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1742 /* Restore the parent's signal handlers. */ |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1743 sigaction (SIGINT, &sigint_action, 0); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1744 sigaction (SIGQUIT, &sigquit_action, 0); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1745 #ifdef AIX |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1746 sigaction (SIGHUP, &sighup_action, 0); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1747 #endif |
|
41856
0028402ed7d1
(create_process): Use HAVE_WORKING_VFORK, not HAVE_VFORK.
Paul Eggert <eggert@twinsun.com>
parents:
40656
diff
changeset
|
1748 #endif /* HAVE_WORKING_VFORK */ |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1749 /* Stop blocking signals in the parent. */ |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1750 sigprocmask (SIG_SETMASK, &procmask, 0); |
|
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1751 #else /* !POSIX_SIGNALS */ |
| 578 | 1752 #ifdef SIGCHLD |
| 1753 #ifdef BSD4_1 | |
| 1754 sigrelse (SIGCHLD); | |
| 1755 #else /* not BSD4_1 */ | |
|
16220
02044b05d8e0
Replaced symbol BSD with BSD_SYSTEM.
Karl Heuer <kwzh@gnu.org>
parents:
16206
diff
changeset
|
1756 #if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX) |
| 578 | 1757 sigsetmask (SIGEMPTYMASK); |
| 1758 #else /* ordinary USG */ | |
| 1759 #if 0 | |
| 1760 signal (SIGCHLD, sigchld); | |
| 1761 /* Now really handle any of these signals | |
| 1762 that came in during this function. */ | |
| 1763 if (sigchld_deferred) | |
| 1764 kill (getpid (), SIGCHLD); | |
| 1765 #endif | |
| 1766 #endif /* ordinary USG */ | |
| 1767 #endif /* not BSD4_1 */ | |
| 1768 #endif /* SIGCHLD */ | |
|
13709
d16f31ae8adf
(create_process): Use Posix signal handling to
Karl Heuer <kwzh@gnu.org>
parents:
13414
diff
changeset
|
1769 #endif /* !POSIX_SIGNALS */ |
|
14131
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1770 |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1771 /* Now generate the error if vfork failed. */ |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1772 if (pid < 0) |
|
7717b68abd2e
(create_process): Restore the signal state
Karl Heuer <kwzh@gnu.org>
parents:
14085
diff
changeset
|
1773 report_file_error ("Doing vfork", Qnil); |
| 578 | 1774 } |
| 1775 #endif /* not VMS */ | |
| 1776 | |
| 1777 #ifdef HAVE_SOCKETS | |
| 1778 | |
| 1779 /* open a TCP network connection to a given HOST/SERVICE. Treated | |
| 1780 exactly like a normal process when reading and writing. Only | |
| 1781 differences are in status display and process deletion. A network | |
| 1782 connection has no PID; you cannot signal it. All you can do is | |
| 1783 deactivate and close it via delete-process */ | |
| 1784 | |
| 1785 DEFUN ("open-network-stream", Fopen_network_stream, Sopen_network_stream, | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1786 4, 7, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1787 doc: /* Open a TCP connection for a service to a host. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1788 Returns a subprocess-object to represent the connection. |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1789 Returns nil if a non-blocking connect is attempted on a system which |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1790 cannot support that; in that case, the caller should attempt a |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1791 normal connect instead. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1792 |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1793 Input and output work as for subprocesses; `delete-process' closes it. |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1794 Args are NAME BUFFER HOST SERVICE FILTER SENTINEL NON-BLOCKING. |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1795 NAME is name for process. It is modified if necessary to make it unique. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1796 BUFFER is the buffer (or buffer-name) to associate with the process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1797 Process output goes at end of that buffer, unless you specify |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1798 an output stream or filter function to handle the output. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
1799 BUFFER may be also nil, meaning that this process is not associated |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1800 with any buffer. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1801 HOST is name of the host to connect to, or its IP address. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1802 SERVICE is name of the service desired, or an integer specifying a |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1803 port number to connect to. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1804 FILTER and SENTINEL are optional args specifying the filter and |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1805 sentinel functions associated with the network stream. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1806 NON-BLOCKING is optional arg requesting an non-blocking connect. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1807 When non-nil, open-network-stream will return immediately without |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1808 waiting for the connection to be made. Instead, the sentinel function |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1809 will be called with second matching "open" (if successful) or |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1810 "failed" when the connect completes. */) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1811 (name, buffer, host, service, filter, sentinel, non_blocking) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1812 Lisp_Object name, buffer, host, service, filter, sentinel, non_blocking; |
| 578 | 1813 { |
| 1814 Lisp_Object proc; | |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1815 #ifdef HAVE_GETADDRINFO |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1816 struct addrinfo hints, *res, *lres; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1817 char *portstring, portbuf[128]; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1818 #else /* HAVE_GETADDRINFO */ |
| 578 | 1819 struct sockaddr_in address; |
| 1820 struct servent *svc_info; | |
| 1821 struct hostent *host_info_ptr, host_info; | |
| 1822 char *(addr_list[2]); | |
|
4998
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
1823 IN_ADDR numeric_addr; |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1824 int port; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1825 struct _emacs_addrinfo |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1826 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1827 int ai_family; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1828 int ai_socktype; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1829 int ai_protocol; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1830 int ai_addrlen; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1831 struct sockaddr *ai_addr; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1832 struct _emacs_addrinfo *ai_next; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1833 } ai, *res, *lres; |
|
25262
ccf83ed7326a
(Fopen_network_stream): Fix previous change.
Karl Heuer <kwzh@gnu.org>
parents:
25248
diff
changeset
|
1834 #endif /* HAVE_GETADDRINFO */ |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1835 int ret = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1836 int xerrno = 0; |
|
25262
ccf83ed7326a
(Fopen_network_stream): Fix previous change.
Karl Heuer <kwzh@gnu.org>
parents:
25248
diff
changeset
|
1837 int s = -1, outch, inch; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1838 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
|
7220
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
1839 int retry = 0; |
|
7486
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
1840 int count = specpdl_ptr - specpdl; |
|
25705
1f109108fa7e
(Fopen_network_stream): Avoid socket decriptor leak.
Andreas Schwab <schwab@suse.de>
parents:
25645
diff
changeset
|
1841 int count1; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1842 int is_non_blocking = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1843 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1844 if (!NILP (non_blocking)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1845 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1846 #ifndef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1847 return Qnil; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1848 #else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1849 non_blocking = Qt; /* Instead of GCPRO */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1850 is_non_blocking = 1; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1851 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1852 } |
| 578 | 1853 |
|
15355
6bb377ef707f
(Fopen_network_stream)[WINDOWSNT]: Ensure Windows
Richard M. Stallman <rms@gnu.org>
parents:
15092
diff
changeset
|
1854 #ifdef WINDOWSNT |
|
6bb377ef707f
(Fopen_network_stream)[WINDOWSNT]: Ensure Windows
Richard M. Stallman <rms@gnu.org>
parents:
15092
diff
changeset
|
1855 /* Ensure socket support is loaded if available. */ |
|
6bb377ef707f
(Fopen_network_stream)[WINDOWSNT]: Ensure Windows
Richard M. Stallman <rms@gnu.org>
parents:
15092
diff
changeset
|
1856 init_winsock (TRUE); |
|
6bb377ef707f
(Fopen_network_stream)[WINDOWSNT]: Ensure Windows
Richard M. Stallman <rms@gnu.org>
parents:
15092
diff
changeset
|
1857 #endif |
|
6bb377ef707f
(Fopen_network_stream)[WINDOWSNT]: Ensure Windows
Richard M. Stallman <rms@gnu.org>
parents:
15092
diff
changeset
|
1858 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1859 /* Can only GCPRO 5 variables */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1860 sentinel = Fcons (sentinel, filter); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1861 GCPRO5 (name, buffer, host, service, sentinel); |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1862 CHECK_STRING (name); |
|
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1863 CHECK_STRING (host); |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1864 |
|
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1865 #ifdef HAVE_GETADDRINFO |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1866 /* SERVICE can either be a string or int. |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1867 Convert to a C string for later use by getaddrinfo. */ |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1868 if (INTEGERP (service)) |
|
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1869 { |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1870 sprintf (portbuf, "%ld", (long) XINT (service)); |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1871 portstring = portbuf; |
|
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1872 } |
|
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1873 else |
|
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1874 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1875 CHECK_STRING (service); |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1876 portstring = XSTRING (service)->data; |
|
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1877 } |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1878 #else /* HAVE_GETADDRINFO */ |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
1879 if (INTEGERP (service)) |
| 578 | 1880 port = htons ((unsigned short) XINT (service)); |
| 1881 else | |
| 1882 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
1883 CHECK_STRING (service); |
| 578 | 1884 svc_info = getservbyname (XSTRING (service)->data, "tcp"); |
| 1885 if (svc_info == 0) | |
| 1886 error ("Unknown service \"%s\"", XSTRING (service)->data); | |
| 1887 port = svc_info->s_port; | |
| 1888 } | |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1889 #endif /* HAVE_GETADDRINFO */ |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1890 |
| 578 | 1891 |
|
13777
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1892 /* Slow down polling to every ten seconds. |
|
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1893 Some kernels have a bug which causes retrying connect to fail |
|
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1894 after a connect. Polling can interfere with gethostbyname too. */ |
|
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1895 #ifdef POLL_FOR_INPUT |
|
27669
5fddc840c29c
(Fopen_network_stream) [POLL_FOR_INPUT]: Register
Gerd Moellmann <gerd@gnu.org>
parents:
27558
diff
changeset
|
1896 record_unwind_protect (unwind_stop_other_atimers, Qnil); |
|
13777
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1897 bind_polling_period (10); |
|
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1898 #endif |
|
5e0cbd5fcb46
(Fopen_network_stream): Call bind_polling_period earlier.
Karl Heuer <kwzh@gnu.org>
parents:
13709
diff
changeset
|
1899 |
|
4914
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
1900 #ifndef TERM |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1901 #ifdef HAVE_GETADDRINFO |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1902 immediate_quit = 1; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1903 QUIT; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1904 memset (&hints, 0, sizeof (hints)); |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1905 hints.ai_flags = 0; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1906 hints.ai_family = AF_UNSPEC; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1907 hints.ai_socktype = SOCK_STREAM; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1908 hints.ai_protocol = 0; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1909 ret = getaddrinfo (XSTRING (host)->data, portstring, &hints, &res); |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1910 if (ret) |
|
32074
a889f9fc59a7
(Fopen_network_stream): Use HAVE_GAI_STRERROR.
Dave Love <fx@gnu.org>
parents:
32032
diff
changeset
|
1911 #ifdef HAVE_GAI_STRERROR |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1912 error ("%s/%s %s", XSTRING (host)->data, portstring, gai_strerror(ret)); |
|
32074
a889f9fc59a7
(Fopen_network_stream): Use HAVE_GAI_STRERROR.
Dave Love <fx@gnu.org>
parents:
32032
diff
changeset
|
1913 #else |
|
a889f9fc59a7
(Fopen_network_stream): Use HAVE_GAI_STRERROR.
Dave Love <fx@gnu.org>
parents:
32032
diff
changeset
|
1914 error ("%s/%s getaddrinfo error %d", XSTRING (host)->data, portstring, |
|
a889f9fc59a7
(Fopen_network_stream): Use HAVE_GAI_STRERROR.
Dave Love <fx@gnu.org>
parents:
32032
diff
changeset
|
1915 ret); |
|
a889f9fc59a7
(Fopen_network_stream): Use HAVE_GAI_STRERROR.
Dave Love <fx@gnu.org>
parents:
32032
diff
changeset
|
1916 #endif |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1917 immediate_quit = 0; |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1918 |
|
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1919 #else /* not HAVE_GETADDRINFO */ |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
1920 |
|
8287
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1921 while (1) |
|
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1922 { |
|
26019
079b0f1b92be
(Fopen_network_stream): Don't loop if gethostbyname
Gerd Moellmann <gerd@gnu.org>
parents:
25894
diff
changeset
|
1923 #if 0 |
|
8331
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
1924 #ifdef TRY_AGAIN |
|
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
1925 h_errno = 0; |
|
14ddb4c66461
[!HAVE_H_ERRNO]: Declare h_errno.
Richard M. Stallman <rms@gnu.org>
parents:
8287
diff
changeset
|
1926 #endif |
|
26019
079b0f1b92be
(Fopen_network_stream): Don't loop if gethostbyname
Gerd Moellmann <gerd@gnu.org>
parents:
25894
diff
changeset
|
1927 #endif |
|
14758
849458c13c0c
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14736
diff
changeset
|
1928 immediate_quit = 1; |
|
849458c13c0c
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14736
diff
changeset
|
1929 QUIT; |
|
8287
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1930 host_info_ptr = gethostbyname (XSTRING (host)->data); |
|
14758
849458c13c0c
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14736
diff
changeset
|
1931 immediate_quit = 0; |
|
26019
079b0f1b92be
(Fopen_network_stream): Don't loop if gethostbyname
Gerd Moellmann <gerd@gnu.org>
parents:
25894
diff
changeset
|
1932 #if 0 |
|
8287
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1933 #ifdef TRY_AGAIN |
|
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1934 if (! (host_info_ptr == 0 && h_errno == TRY_AGAIN)) |
|
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1935 #endif |
|
26019
079b0f1b92be
(Fopen_network_stream): Don't loop if gethostbyname
Gerd Moellmann <gerd@gnu.org>
parents:
25894
diff
changeset
|
1936 #endif |
|
8287
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1937 break; |
|
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1938 Fsleep_for (make_number (1), Qnil); |
|
97c2535b7f37
(Fopen_network_stream): Retry gethostbyname after TRY_AGAIN failure.
Richard M. Stallman <rms@gnu.org>
parents:
8231
diff
changeset
|
1939 } |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
1940 |
| 578 | 1941 if (host_info_ptr == 0) |
| 1942 /* Attempt to interpret host as numeric inet address */ | |
| 1943 { | |
|
4883
a806d71f58f6
(Fopen_netwrok_stream): Cast arg to inet_addr to (char *).
Brian Fox <bfox@gnu.org>
parents:
4870
diff
changeset
|
1944 numeric_addr = inet_addr ((char *) XSTRING (host)->data); |
|
4998
3cd3a39f98f4
(IN_ADDR, NUMERIC_ADDR_ERROR): New macros (two versions).
Richard M. Stallman <rms@gnu.org>
parents:
4994
diff
changeset
|
1945 if (NUMERIC_ADDR_ERROR) |
| 578 | 1946 error ("Unknown host \"%s\"", XSTRING (host)->data); |
| 1947 | |
| 1948 host_info_ptr = &host_info; | |
| 1949 host_info.h_name = 0; | |
| 1950 host_info.h_aliases = 0; | |
| 1951 host_info.h_addrtype = AF_INET; | |
|
2944
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1952 #ifdef h_addr |
|
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1953 /* Older machines have only one address slot called h_addr. |
|
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1954 Newer machines have h_addr_list, but #define h_addr to |
|
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1955 be its first element. */ |
|
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1956 host_info.h_addr_list = &(addr_list[0]); |
|
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1957 #endif |
|
f66a150d3fb9
* process.c (Fopen_network_stream): Deal with older systems, which
Jim Blandy <jimb@redhat.com>
parents:
2917
diff
changeset
|
1958 host_info.h_addr = (char*)(&numeric_addr); |
| 578 | 1959 addr_list[1] = 0; |
|
14544
ef07b51330af
(Fopen_network_stream): Use sizeof, not strlen, for numeric_addr.
Richard M. Stallman <rms@gnu.org>
parents:
14513
diff
changeset
|
1960 /* numeric_addr isn't null-terminated; it has fixed length. */ |
|
ef07b51330af
(Fopen_network_stream): Use sizeof, not strlen, for numeric_addr.
Richard M. Stallman <rms@gnu.org>
parents:
14513
diff
changeset
|
1961 host_info.h_length = sizeof (numeric_addr); |
| 578 | 1962 } |
| 1963 | |
| 1964 bzero (&address, sizeof address); | |
| 1965 bcopy (host_info_ptr->h_addr, (char *) &address.sin_addr, | |
| 1966 host_info_ptr->h_length); | |
| 1967 address.sin_family = host_info_ptr->h_addrtype; | |
| 1968 address.sin_port = port; | |
| 1969 | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1970 /* Emulate HAVE_GETADDRINFO for the loop over `res' below. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1971 ai.ai_family = host_info_ptr->h_addrtype; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1972 ai.ai_socktype = SOCK_STREAM; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1973 ai.ai_protocol = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1974 ai.ai_addr = (struct sockaddr *) &address; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1975 ai.ai_addrlen = sizeof address; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1976 ai.ai_next = NULL; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1977 res = &ai; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1978 #endif /* not HAVE_GETADDRINFO */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1979 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1980 /* Do this in case we never enter the for-loop below. */ |
|
25705
1f109108fa7e
(Fopen_network_stream): Avoid socket decriptor leak.
Andreas Schwab <schwab@suse.de>
parents:
25645
diff
changeset
|
1981 count1 = specpdl_ptr - specpdl; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1982 s = -1; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1983 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1984 for (lres = res; lres; lres = lres->ai_next) |
| 578 | 1985 { |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1986 s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1987 if (s < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1988 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1989 xerrno = errno; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1990 continue; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1991 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1992 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1993 #ifdef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1994 if (is_non_blocking) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1995 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1996 #ifdef O_NONBLOCK |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1997 ret = fcntl (s, F_SETFL, O_NONBLOCK); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1998 #else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
1999 ret = fcntl (s, F_SETFL, O_NDELAY); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2000 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2001 if (ret < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2002 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2003 xerrno = errno; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2004 emacs_close (s); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2005 s = -1; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2006 continue; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2007 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2008 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2009 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2010 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2011 /* Kernel bugs (on Ultrix at least) cause lossage (not just EINTR) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2012 when connect is interrupted. So let's not let it get interrupted. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2013 Note we do not turn off polling, because polling is only used |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2014 when not interrupt_input, and thus not normally used on the systems |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2015 which have this bug. On systems which use polling, there's no way |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2016 to quit if polling is turned off. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2017 if (interrupt_input) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2018 unrequest_sigio (); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2019 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2020 /* Make us close S if quit. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2021 count1 = specpdl_ptr - specpdl; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2022 record_unwind_protect (close_file_unwind, make_number (s)); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2023 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2024 loop: |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2025 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2026 immediate_quit = 1; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2027 QUIT; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2028 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2029 /* This turns off all alarm-based interrupts; the |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2030 bind_polling_period call above doesn't always turn all the |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2031 short-interval ones off, especially if interrupt_input is |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2032 set. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2033 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2034 It'd be nice to be able to control the connect timeout |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2035 though. Would non-blocking connect calls be portable? |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2036 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2037 This used to be conditioned by HAVE_GETADDRINFO. Why? */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2038 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2039 if (!is_non_blocking) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2040 turn_on_atimers (0); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2041 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2042 ret = connect (s, lres->ai_addr, lres->ai_addrlen); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2043 xerrno = errno; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2044 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2045 if (!is_non_blocking) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2046 turn_on_atimers (1); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2047 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2048 if (ret == 0 || xerrno == EISCONN) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2049 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2050 is_non_blocking = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2051 /* The unwind-protect will be discarded afterwards. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2052 Likewise for immediate_quit. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2053 break; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2054 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2055 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2056 #ifdef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2057 #ifdef EINPROGRESS |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2058 if (is_non_blocking && xerrno == EINPROGRESS) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2059 break; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2060 #else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2061 #ifdef EWOULDBLOCK |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2062 if (is_non_blocking && xerrno == EWOULDBLOCK) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2063 break; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2064 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2065 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2066 #endif |
|
7220
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
2067 |
|
14671
0493e857a13b
(Fopen_network_stream): Set immediate_quit for the connect.
Richard M. Stallman <rms@gnu.org>
parents:
14613
diff
changeset
|
2068 immediate_quit = 0; |
|
0493e857a13b
(Fopen_network_stream): Set immediate_quit for the connect.
Richard M. Stallman <rms@gnu.org>
parents:
14613
diff
changeset
|
2069 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2070 if (xerrno == EINTR) |
| 578 | 2071 goto loop; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2072 if (xerrno == EADDRINUSE && retry < 20) |
|
7220
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
2073 { |
|
12378
3171d5da8a86
(Fopen_network_stream): Sleep 1 sec before connect retry.
Richard M. Stallman <rms@gnu.org>
parents:
12324
diff
changeset
|
2074 /* A delay here is needed on some FreeBSD systems, |
|
3171d5da8a86
(Fopen_network_stream): Sleep 1 sec before connect retry.
Richard M. Stallman <rms@gnu.org>
parents:
12324
diff
changeset
|
2075 and it is harmless, since this retrying takes time anyway |
|
3171d5da8a86
(Fopen_network_stream): Sleep 1 sec before connect retry.
Richard M. Stallman <rms@gnu.org>
parents:
12324
diff
changeset
|
2076 and should be infrequent. */ |
|
3171d5da8a86
(Fopen_network_stream): Sleep 1 sec before connect retry.
Richard M. Stallman <rms@gnu.org>
parents:
12324
diff
changeset
|
2077 Fsleep_for (make_number (1), Qnil); |
|
7220
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
2078 retry++; |
|
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
2079 goto loop; |
|
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
2080 } |
|
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
2081 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2082 /* Discard the unwind protect closing S. */ |
|
25705
1f109108fa7e
(Fopen_network_stream): Avoid socket decriptor leak.
Andreas Schwab <schwab@suse.de>
parents:
25645
diff
changeset
|
2083 specpdl_ptr = specpdl + count1; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2084 count1 = specpdl_ptr - specpdl; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2085 |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
2086 emacs_close (s); |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2087 s = -1; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2088 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2089 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2090 #ifdef HAVE_GETADDRINFO |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2091 freeaddrinfo (res); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2092 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2093 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2094 if (s < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2095 { |
|
5332
c559b3d1b9e4
(Fopen_network_stream): Turn off SIGIO while connecting.
Richard M. Stallman <rms@gnu.org>
parents:
5240
diff
changeset
|
2096 if (interrupt_input) |
|
c559b3d1b9e4
(Fopen_network_stream): Turn off SIGIO while connecting.
Richard M. Stallman <rms@gnu.org>
parents:
5240
diff
changeset
|
2097 request_sigio (); |
|
c559b3d1b9e4
(Fopen_network_stream): Turn off SIGIO while connecting.
Richard M. Stallman <rms@gnu.org>
parents:
5240
diff
changeset
|
2098 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2099 /* If non-blocking got this far - and failed - assume non-blocking is |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2100 not supported after all. This is probably a wrong assumption, but |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2101 the normal blocking calls to open-network-stream handles this error |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2102 better. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2103 if (is_non_blocking) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2104 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2105 #ifdef POLL_FOR_INPUT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2106 unbind_to (count, Qnil); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2107 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2108 return Qnil; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2109 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2110 |
| 578 | 2111 errno = xerrno; |
| 2112 report_file_error ("connection failed", | |
| 2113 Fcons (host, Fcons (name, Qnil))); | |
| 2114 } | |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
2115 |
|
14671
0493e857a13b
(Fopen_network_stream): Set immediate_quit for the connect.
Richard M. Stallman <rms@gnu.org>
parents:
14613
diff
changeset
|
2116 immediate_quit = 0; |
|
0493e857a13b
(Fopen_network_stream): Set immediate_quit for the connect.
Richard M. Stallman <rms@gnu.org>
parents:
14613
diff
changeset
|
2117 |
|
32032
633b826a56f3
(Fopen_network_stream) [HAVE_GETADDRINFO]: Use
Gerd Moellmann <gerd@gnu.org>
parents:
31806
diff
changeset
|
2118 /* Discard the unwind protect, if any. */ |
|
25705
1f109108fa7e
(Fopen_network_stream): Avoid socket decriptor leak.
Andreas Schwab <schwab@suse.de>
parents:
25645
diff
changeset
|
2119 specpdl_ptr = specpdl + count1; |
|
1f109108fa7e
(Fopen_network_stream): Avoid socket decriptor leak.
Andreas Schwab <schwab@suse.de>
parents:
25645
diff
changeset
|
2120 |
|
7486
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
2121 #ifdef POLL_FOR_INPUT |
|
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
2122 unbind_to (count, Qnil); |
|
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
2123 #endif |
|
cfe4840ffde9
(Fopen_network_stream): Call bind_polling_period; later unbind the binding.
Richard M. Stallman <rms@gnu.org>
parents:
7454
diff
changeset
|
2124 |
|
5332
c559b3d1b9e4
(Fopen_network_stream): Turn off SIGIO while connecting.
Richard M. Stallman <rms@gnu.org>
parents:
5240
diff
changeset
|
2125 if (interrupt_input) |
|
c559b3d1b9e4
(Fopen_network_stream): Turn off SIGIO while connecting.
Richard M. Stallman <rms@gnu.org>
parents:
5240
diff
changeset
|
2126 request_sigio (); |
|
c559b3d1b9e4
(Fopen_network_stream): Turn off SIGIO while connecting.
Richard M. Stallman <rms@gnu.org>
parents:
5240
diff
changeset
|
2127 |
|
4914
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2128 #else /* TERM */ |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2129 s = connect_server (0); |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2130 if (s < 0) |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2131 report_file_error ("error creating socket", Fcons (name, Qnil)); |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2132 send_command (s, C_PORT, 0, "%s:%d", XSTRING (host)->data, ntohs (port)); |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2133 send_command (s, C_DUMB, 1, 0); |
|
56bc426b1eb4
[TERM]: Include client.h.
Richard M. Stallman <rms@gnu.org>
parents:
4883
diff
changeset
|
2134 #endif /* TERM */ |
| 578 | 2135 |
| 2136 inch = s; | |
|
17247
351006378b51
(Fopen_network_stream): Use same socket for in and out.
Richard M. Stallman <rms@gnu.org>
parents:
17224
diff
changeset
|
2137 outch = s; |
| 578 | 2138 |
| 2139 if (!NILP (buffer)) | |
| 2140 buffer = Fget_buffer_create (buffer); | |
| 2141 proc = make_process (name); | |
| 2142 | |
| 2143 chan_process[inch] = proc; | |
| 2144 | |
| 2145 #ifdef O_NONBLOCK | |
| 2146 fcntl (inch, F_SETFL, O_NONBLOCK); | |
| 2147 #else | |
| 2148 #ifdef O_NDELAY | |
| 2149 fcntl (inch, F_SETFL, O_NDELAY); | |
| 2150 #endif | |
| 2151 #endif | |
| 2152 | |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
2153 XPROCESS (proc)->childp = Fcons (host, Fcons (service, Qnil)); |
| 578 | 2154 XPROCESS (proc)->command_channel_p = Qnil; |
| 2155 XPROCESS (proc)->buffer = buffer; | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2156 XPROCESS (proc)->sentinel = XCAR (sentinel); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2157 XPROCESS (proc)->filter = XCDR (sentinel); |
| 578 | 2158 XPROCESS (proc)->command = Qnil; |
| 2159 XPROCESS (proc)->pid = Qnil; | |
|
15092
5372670fbe59
(Fopen_network_stream): Set process infd to inch.
Richard M. Stallman <rms@gnu.org>
parents:
15064
diff
changeset
|
2160 XSETINT (XPROCESS (proc)->infd, inch); |
|
9277
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
2161 XSETINT (XPROCESS (proc)->outfd, outch); |
| 578 | 2162 XPROCESS (proc)->status = Qrun; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2163 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2164 #ifdef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2165 if (!NILP (non_blocking)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2166 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2167 /* We may get here if connect did succeed immediately. However, |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2168 in that case, we still need to signal this like a non-blocking |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2169 connection. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2170 XPROCESS (proc)->status = Qconnect; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2171 if (!FD_ISSET (inch, &connect_wait_mask)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2172 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2173 FD_SET (inch, &connect_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2174 num_pending_connects++; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2175 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2176 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2177 else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2178 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2179 if (!EQ (XPROCESS (proc)->filter, Qt)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2180 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2181 FD_SET (inch, &input_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2182 FD_SET (inch, &non_keyboard_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2183 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2184 |
|
7044
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2185 if (inch > max_process_desc) |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2186 max_process_desc = inch; |
| 578 | 2187 |
|
22019
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2188 { |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2189 /* Setup coding systems for communicating with the network stream. */ |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2190 struct gcpro gcpro1; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2191 /* Qt denotes we have not yet called Ffind_operation_coding_system. */ |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2192 Lisp_Object coding_systems = Qt; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2193 Lisp_Object args[5], val; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2194 |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2195 if (!NILP (Vcoding_system_for_read)) |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2196 val = Vcoding_system_for_read; |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
2197 else if ((!NILP (buffer) && NILP (XBUFFER (buffer)->enable_multibyte_characters)) |
|
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
2198 || (NILP (buffer) && NILP (buffer_defaults.enable_multibyte_characters))) |
|
22019
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2199 /* We dare not decode end-of-line format by setting VAL to |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2200 Qraw_text, because the existing Emacs Lisp libraries |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2201 assume that they receive bare code including a sequene of |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2202 CR LF. */ |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2203 val = Qnil; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2204 else |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2205 { |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2206 args[0] = Qopen_network_stream, args[1] = name, |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2207 args[2] = buffer, args[3] = host, args[4] = service; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2208 GCPRO1 (proc); |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2209 coding_systems = Ffind_operation_coding_system (5, args); |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2210 UNGCPRO; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2211 if (CONSP (coding_systems)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
2212 val = XCAR (coding_systems); |
|
22019
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2213 else if (CONSP (Vdefault_process_coding_system)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
2214 val = XCAR (Vdefault_process_coding_system); |
|
22019
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2215 else |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2216 val = Qnil; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2217 } |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2218 XPROCESS (proc)->decode_coding_system = val; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2219 |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2220 if (!NILP (Vcoding_system_for_write)) |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2221 val = Vcoding_system_for_write; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2222 else if (NILP (current_buffer->enable_multibyte_characters)) |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2223 val = Qnil; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2224 else |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2225 { |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2226 if (EQ (coding_systems, Qt)) |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2227 { |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2228 args[0] = Qopen_network_stream, args[1] = name, |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2229 args[2] = buffer, args[3] = host, args[4] = service; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2230 GCPRO1 (proc); |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2231 coding_systems = Ffind_operation_coding_system (5, args); |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2232 UNGCPRO; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2233 } |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2234 if (CONSP (coding_systems)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
2235 val = XCDR (coding_systems); |
|
22019
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2236 else if (CONSP (Vdefault_process_coding_system)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
2237 val = XCDR (Vdefault_process_coding_system); |
|
22019
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2238 else |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2239 val = Qnil; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2240 } |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2241 XPROCESS (proc)->encode_coding_system = val; |
|
bb9dd4758e7e
(Fstart_process): Remove the special case for
Richard M. Stallman <rms@gnu.org>
parents:
21978
diff
changeset
|
2242 } |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2243 |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2244 if (!proc_decode_coding_system[inch]) |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2245 proc_decode_coding_system[inch] |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2246 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
2247 setup_coding_system (XPROCESS (proc)->decode_coding_system, |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2248 proc_decode_coding_system[inch]); |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2249 if (!proc_encode_coding_system[outch]) |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2250 proc_encode_coding_system[outch] |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2251 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
2252 setup_coding_system (XPROCESS (proc)->encode_coding_system, |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
2253 proc_encode_coding_system[outch]); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
2254 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
2255 XPROCESS (proc)->decoding_buf = make_uninit_string (0); |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2256 XPROCESS (proc)->decoding_carryover = make_number (0); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
2257 XPROCESS (proc)->encoding_buf = make_uninit_string (0); |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
2258 XPROCESS (proc)->encoding_carryover = make_number (0); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
2259 |
|
21848
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
2260 XPROCESS (proc)->inherit_coding_system_flag |
|
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
2261 = (NILP (buffer) || !inherit_process_coding_system |
|
050ea21cec87
(Fset_process_inherit_coding_system_flag, Fstart_process):
Richard M. Stallman <rms@gnu.org>
parents:
21798
diff
changeset
|
2262 ? Qnil : Qt); |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
2263 |
| 578 | 2264 UNGCPRO; |
| 2265 return proc; | |
| 2266 } | |
| 2267 #endif /* HAVE_SOCKETS */ | |
| 2268 | |
|
20382
dbad9367d232
(create_process, deactivate_process, close_process_descs):
Andreas Schwab <schwab@suse.de>
parents:
20225
diff
changeset
|
2269 void |
| 578 | 2270 deactivate_process (proc) |
| 2271 Lisp_Object proc; | |
| 2272 { | |
| 2273 register int inchannel, outchannel; | |
| 2274 register struct Lisp_Process *p = XPROCESS (proc); | |
| 2275 | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2276 inchannel = XINT (p->infd); |
|
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2277 outchannel = XINT (p->outfd); |
|
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2278 |
|
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2279 if (inchannel >= 0) |
| 578 | 2280 { |
| 2281 /* Beware SIGCHLD hereabouts. */ | |
| 2282 flush_pending_output (inchannel); | |
| 2283 #ifdef VMS | |
| 2284 { | |
| 2285 VMS_PROC_STUFF *get_vms_process_pointer (), *vs; | |
| 2286 sys$dassgn (outchannel); | |
|
2357
9faa3a02ea97
* process.c [VMS] (DCL_PROMPT): Remove hack.
Jim Blandy <jimb@redhat.com>
parents:
2290
diff
changeset
|
2287 vs = get_vms_process_pointer (p->pid); |
| 578 | 2288 if (vs) |
| 2289 give_back_vms_process_stuff (vs); | |
| 2290 } | |
| 2291 #else | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
2292 emacs_close (inchannel); |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2293 if (outchannel >= 0 && outchannel != inchannel) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
2294 emacs_close (outchannel); |
| 578 | 2295 #endif |
| 2296 | |
|
9277
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
2297 XSETINT (p->infd, -1); |
|
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
2298 XSETINT (p->outfd, -1); |
| 578 | 2299 chan_process[inchannel] = Qnil; |
| 2300 FD_CLR (inchannel, &input_wait_mask); | |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
2301 FD_CLR (inchannel, &non_keyboard_wait_mask); |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2302 if (FD_ISSET (inchannel, &connect_wait_mask)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2303 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2304 FD_CLR (inchannel, &connect_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2305 if (--num_pending_connects < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2306 abort (); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2307 } |
|
7044
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2308 if (inchannel == max_process_desc) |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2309 { |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2310 int i; |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2311 /* We just closed the highest-numbered process input descriptor, |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2312 so recompute the highest-numbered one now. */ |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2313 max_process_desc = 0; |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2314 for (i = 0; i < MAXDESC; i++) |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2315 if (!NILP (chan_process[i])) |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2316 max_process_desc = i; |
|
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
2317 } |
| 578 | 2318 } |
| 2319 } | |
| 2320 | |
| 2321 /* Close all descriptors currently in use for communication | |
| 2322 with subprocess. This is used in a newly-forked subprocess | |
| 2323 to get rid of irrelevant descriptors. */ | |
| 2324 | |
|
20382
dbad9367d232
(create_process, deactivate_process, close_process_descs):
Andreas Schwab <schwab@suse.de>
parents:
20225
diff
changeset
|
2325 void |
| 578 | 2326 close_process_descs () |
| 2327 { | |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
2328 #ifndef WINDOWSNT |
| 578 | 2329 int i; |
| 2330 for (i = 0; i < MAXDESC; i++) | |
| 2331 { | |
| 2332 Lisp_Object process; | |
| 2333 process = chan_process[i]; | |
| 2334 if (!NILP (process)) | |
| 2335 { | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2336 int in = XINT (XPROCESS (process)->infd); |
|
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2337 int out = XINT (XPROCESS (process)->outfd); |
|
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2338 if (in >= 0) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
2339 emacs_close (in); |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2340 if (out >= 0 && in != out) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
2341 emacs_close (out); |
| 578 | 2342 } |
| 2343 } | |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
2344 #endif |
| 578 | 2345 } |
| 2346 | |
| 2347 DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2348 0, 3, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2349 doc: /* Allow any pending output from subprocesses to be read by Emacs. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2350 It is read into the process' buffers or given to their filter functions. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2351 Non-nil arg PROCESS means do not return until some output has been received |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2352 from PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2353 Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2354 seconds and microseconds to wait; return after that much time whether |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2355 or not there is input. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2356 Return non-nil iff we received any output before the timeout expired. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2357 (process, timeout, timeout_msecs) |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2358 register Lisp_Object process, timeout, timeout_msecs; |
| 578 | 2359 { |
| 2360 int seconds; | |
| 2361 int useconds; | |
| 2362 | |
|
24598
078d53377010
(Faccept_process_output): Check validity of PROCESS.
Richard M. Stallman <rms@gnu.org>
parents:
24352
diff
changeset
|
2363 if (! NILP (process)) |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
2364 CHECK_PROCESS (process); |
|
24598
078d53377010
(Faccept_process_output): Check validity of PROCESS.
Richard M. Stallman <rms@gnu.org>
parents:
24352
diff
changeset
|
2365 |
| 578 | 2366 if (! NILP (timeout_msecs)) |
| 2367 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
2368 CHECK_NUMBER (timeout_msecs); |
| 578 | 2369 useconds = XINT (timeout_msecs); |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
2370 if (!INTEGERP (timeout)) |
|
9277
21f6120be5ba
(make_process, create_process, Fopen_network_stream, deactivate_process,
Karl Heuer <kwzh@gnu.org>
parents:
9115
diff
changeset
|
2371 XSETINT (timeout, 0); |
| 578 | 2372 |
| 2373 { | |
| 2374 int carry = useconds / 1000000; | |
| 2375 | |
| 2376 XSETINT (timeout, XINT (timeout) + carry); | |
| 2377 useconds -= carry * 1000000; | |
| 2378 | |
| 2379 /* I think this clause is necessary because C doesn't | |
| 2380 guarantee a particular rounding direction for negative | |
| 2381 integers. */ | |
| 2382 if (useconds < 0) | |
| 2383 { | |
| 2384 XSETINT (timeout, XINT (timeout) - 1); | |
| 2385 useconds += 1000000; | |
| 2386 } | |
| 2387 } | |
| 2388 } | |
|
1180
9bf82484415d
(Faccept_process_output): Initialize useconds.
Richard M. Stallman <rms@gnu.org>
parents:
1047
diff
changeset
|
2389 else |
|
9bf82484415d
(Faccept_process_output): Initialize useconds.
Richard M. Stallman <rms@gnu.org>
parents:
1047
diff
changeset
|
2390 useconds = 0; |
| 578 | 2391 |
| 2392 if (! NILP (timeout)) | |
| 2393 { | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
2394 CHECK_NUMBER (timeout); |
| 578 | 2395 seconds = XINT (timeout); |
|
14605
80196bfd8b94
(Faccept_process_output): Accept sub-second timeouts.
Erik Naggum <erik@naggum.no>
parents:
14544
diff
changeset
|
2396 if (seconds < 0 || (seconds == 0 && useconds == 0)) |
| 578 | 2397 seconds = -1; |
| 2398 } | |
| 2399 else | |
| 2400 { | |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2401 if (NILP (process)) |
| 578 | 2402 seconds = -1; |
| 2403 else | |
| 2404 seconds = 0; | |
| 2405 } | |
| 2406 | |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2407 if (NILP (process)) |
|
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2408 XSETFASTINT (process, 0); |
| 650 | 2409 |
| 578 | 2410 return |
|
14085
85ce7bab31dc
(Fprocessp, Fget_buffer_process, Fdelete_process, Fprocess_status,
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
2411 (wait_reading_process_input (seconds, useconds, process, 0) |
| 578 | 2412 ? Qt : Qnil); |
| 2413 } | |
| 2414 | |
| 2415 /* This variable is different from waiting_for_input in keyboard.c. | |
| 2416 It is used to communicate to a lisp process-filter/sentinel (via the | |
| 2417 function Fwaiting_for_user_input_p below) whether emacs was waiting | |
| 2418 for user-input when that process-filter was called. | |
| 2419 waiting_for_input cannot be used as that is by definition 0 when | |
|
8570
dd3dfde8f973
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
8390
diff
changeset
|
2420 lisp code is being evalled. |
|
dd3dfde8f973
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
8390
diff
changeset
|
2421 This is also used in record_asynch_buffer_change. |
|
dd3dfde8f973
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
8390
diff
changeset
|
2422 For that purpose, this must be 0 |
|
dd3dfde8f973
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
8390
diff
changeset
|
2423 when not inside wait_reading_process_input. */ |
| 578 | 2424 static int waiting_for_user_input_p; |
| 2425 | |
|
14890
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2426 /* This is here so breakpoints can be put on it. */ |
| 21514 | 2427 static void |
|
14890
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2428 wait_reading_process_input_1 () |
|
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2429 { |
|
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2430 } |
|
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2431 |
| 578 | 2432 /* Read and dispose of subprocess output while waiting for timeout to |
| 2433 elapse and/or keyboard input to be available. | |
| 2434 | |
|
3953
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2435 TIME_LIMIT is: |
| 578 | 2436 timeout in seconds, or |
| 2437 zero for no limit, or | |
| 2438 -1 means gobble data immediately available but don't wait for any. | |
| 2439 | |
|
3953
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2440 MICROSECS is: |
|
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2441 an additional duration to wait, measured in microseconds. |
|
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2442 If this is nonzero and time_limit is 0, then the timeout |
|
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2443 consists of MICROSECS only. |
|
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2444 |
|
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2445 READ_KBD is a lisp value: |
| 578 | 2446 0 to ignore keyboard input, or |
| 2447 1 to return when input is available, or | |
|
2200
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2448 -1 meaning caller will actually read the input, so don't throw to |
| 578 | 2449 the quit handler, or |
| 6569 | 2450 a cons cell, meaning wait until its car is non-nil |
|
3953
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2451 (and gobble terminal input into the buffer if any arrives), or |
| 650 | 2452 a process object, meaning wait until something arrives from that |
| 2453 process. The return value is true iff we read some input from | |
| 2454 that process. | |
| 578 | 2455 |
|
3953
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2456 DO_DISPLAY != 0 means redisplay should be done to show subprocess |
| 578 | 2457 output that arrives. |
| 2458 | |
|
3953
d0c23febc08c
(wait_reading_process_input): Do include the keyboard
Richard M. Stallman <rms@gnu.org>
parents:
3915
diff
changeset
|
2459 If READ_KBD is a pointer to a struct Lisp_Process, then the |
| 578 | 2460 function returns true iff we received input from that process |
| 2461 before the timeout elapsed. | |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3510
diff
changeset
|
2462 Otherwise, return true iff we received input from any process. */ |
| 578 | 2463 |
| 21514 | 2464 int |
| 578 | 2465 wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) |
| 650 | 2466 int time_limit, microsecs; |
| 2467 Lisp_Object read_kbd; | |
| 2468 int do_display; | |
| 578 | 2469 { |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
2470 register int channel, nfds; |
| 578 | 2471 static SELECT_TYPE Available; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2472 static SELECT_TYPE Connecting; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2473 int check_connect, no_avail; |
| 578 | 2474 int xerrno; |
| 2475 Lisp_Object proc; | |
|
25770
3a44b5298cd5
(list_processes_1): Remove unused variables.
Gerd Moellmann <gerd@gnu.org>
parents:
25760
diff
changeset
|
2476 EMACS_TIME timeout, end_time; |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2477 int wait_channel = -1; |
| 578 | 2478 struct Lisp_Process *wait_proc = 0; |
| 2479 int got_some_input = 0; | |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2480 /* Either nil or a cons cell, the car of which is of interest and |
|
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2481 may be changed outside of this routine. */ |
|
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2482 Lisp_Object wait_for_cell = Qnil; |
| 578 | 2483 |
| 2484 FD_ZERO (&Available); | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2485 FD_ZERO (&Connecting); |
| 578 | 2486 |
| 650 | 2487 /* If read_kbd is a process to watch, set wait_proc and wait_channel |
| 2488 accordingly. */ | |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
2489 if (PROCESSP (read_kbd)) |
| 578 | 2490 { |
| 650 | 2491 wait_proc = XPROCESS (read_kbd); |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2492 wait_channel = XINT (wait_proc->infd); |
|
9318
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
2493 XSETFASTINT (read_kbd, 0); |
| 578 | 2494 } |
| 2495 | |
|
2200
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2496 /* If waiting for non-nil in a cell, record where. */ |
|
9115
59bc2d010b5f
(decode_status, Fprocessp, Fget_process, Fget_buffer_process, Fprocess_status,
Karl Heuer <kwzh@gnu.org>
parents:
9034
diff
changeset
|
2497 if (CONSP (read_kbd)) |
|
2200
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2498 { |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2499 wait_for_cell = read_kbd; |
|
9318
a14cc1712337
(make_process, list_processes_1, create_process, Faccept_process_output,
Karl Heuer <kwzh@gnu.org>
parents:
9277
diff
changeset
|
2500 XSETFASTINT (read_kbd, 0); |
|
2200
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2501 } |
|
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2502 |
| 650 | 2503 waiting_for_user_input_p = XINT (read_kbd); |
| 578 | 2504 |
| 2505 /* Since we may need to wait several times, | |
| 2506 compute the absolute time to return at. */ | |
| 2507 if (time_limit || microsecs) | |
| 2508 { | |
| 2509 EMACS_GET_TIME (end_time); | |
| 2510 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); | |
| 2511 EMACS_ADD_TIME (end_time, end_time, timeout); | |
| 2512 } | |
|
15661
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2513 #ifdef hpux |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2514 /* AlainF 5-Jul-1996 |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2515 HP-UX 10.10 seem to have problems with signals coming in |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2516 Causes "poll: interrupted system call" messages when Emacs is run |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2517 in an X window |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2518 Turn off periodic alarms (in case they are in use) */ |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
2519 turn_on_atimers (0); |
|
15661
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
2520 #endif |
| 578 | 2521 |
| 2522 while (1) | |
| 2523 { | |
|
14458
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2524 int timeout_reduced_for_timers = 0; |
|
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2525 |
| 578 | 2526 /* If calling from keyboard input, do not quit |
| 2527 since we want to return C-g as an input character. | |
| 2528 Otherwise, do pending quit if requested. */ | |
| 650 | 2529 if (XINT (read_kbd) >= 0) |
| 578 | 2530 QUIT; |
| 2531 | |
| 4639 | 2532 /* Exit now if the cell we're waiting for became non-nil. */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2533 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) |
| 4639 | 2534 break; |
| 2535 | |
| 578 | 2536 /* Compute time from now till when time limit is up */ |
| 2537 /* Exit if already run out */ | |
| 2538 if (time_limit == -1) | |
| 2539 { | |
| 2540 /* -1 specified for timeout means | |
| 2541 gobble output available now | |
| 2542 but don't wait at all. */ | |
| 2543 | |
| 2544 EMACS_SET_SECS_USECS (timeout, 0, 0); | |
| 2545 } | |
| 2546 else if (time_limit || microsecs) | |
| 2547 { | |
| 2548 EMACS_GET_TIME (timeout); | |
| 2549 EMACS_SUB_TIME (timeout, end_time, timeout); | |
| 2550 if (EMACS_TIME_NEG_P (timeout)) | |
| 2551 break; | |
| 2552 } | |
| 2553 else | |
| 2554 { | |
| 2555 EMACS_SET_SECS_USECS (timeout, 100000, 0); | |
| 2556 } | |
| 2557 | |
|
15064
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2558 /* Normally we run timers here. |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2559 But not if wait_for_cell; in those cases, |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2560 the wait is supposed to be short, |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2561 and those callers cannot handle running arbitrary Lisp code here. */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2562 if (NILP (wait_for_cell)) |
|
14404
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2563 { |
|
14458
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2564 EMACS_TIME timer_delay; |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2565 |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2566 do |
|
14890
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2567 { |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2568 int old_timers_run = timers_run; |
|
37465
f790d83ea743
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
37413
diff
changeset
|
2569 struct buffer *old_buffer = current_buffer; |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2570 |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2571 timer_delay = timer_check (1); |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2572 |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2573 /* If a timer has run, this might have changed buffers |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2574 an alike. Make read_key_sequence aware of that. */ |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2575 if (timers_run != old_timers_run |
|
37465
f790d83ea743
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
37413
diff
changeset
|
2576 && old_buffer != current_buffer |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2577 && waiting_for_user_input_p == -1) |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2578 record_asynch_buffer_change (); |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2579 |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2580 if (timers_run != old_timers_run && do_display) |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2581 /* We must retry, since a timer may have requeued itself |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2582 and that could alter the time_delay. */ |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
2583 redisplay_preserve_echo_area (9); |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2584 else |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2585 break; |
|
14890
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2586 } |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
2587 while (!detect_input_pending ()); |
|
14890
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2588 |
|
18230
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2589 /* If there is unread keyboard input, also return. */ |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2590 if (XINT (read_kbd) != 0 |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2591 && requeued_events_pending_p ()) |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2592 break; |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2593 |
|
14458
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2594 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) |
|
14404
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2595 { |
|
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2596 EMACS_TIME difference; |
|
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2597 EMACS_SUB_TIME (difference, timer_delay, timeout); |
|
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2598 if (EMACS_TIME_NEG_P (difference)) |
|
14458
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2599 { |
|
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2600 timeout = timer_delay; |
|
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2601 timeout_reduced_for_timers = 1; |
|
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2602 } |
|
14404
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2603 } |
|
14935
3e0dc64a5cb8
(wait_reading_process_input): Don't call
Richard M. Stallman <rms@gnu.org>
parents:
14890
diff
changeset
|
2604 /* If time_limit is -1, we are not going to wait at all. */ |
|
3e0dc64a5cb8
(wait_reading_process_input): Don't call
Richard M. Stallman <rms@gnu.org>
parents:
14890
diff
changeset
|
2605 else if (time_limit != -1) |
|
14890
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2606 { |
|
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2607 /* This is so a breakpoint can be put here. */ |
|
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2608 wait_reading_process_input_1 (); |
|
71c2cf461805
(wait_reading_process_input_1): New (empty) function.
Richard M. Stallman <rms@gnu.org>
parents:
14863
diff
changeset
|
2609 } |
|
14404
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2610 } |
|
cba05f90ee57
(wait_reading_process_input): Call timer_check
Richard M. Stallman <rms@gnu.org>
parents:
14278
diff
changeset
|
2611 |
|
2894
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2612 /* Cause C-g and alarm signals to take immediate action, |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2613 and cause input available signals to zero out timeout. |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2614 |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2615 It is important that we do this before checking for process |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2616 activity. If we get a SIGCHLD after the explicit checks for |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2617 process activity, timeout is the only way we will know. */ |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2618 if (XINT (read_kbd) < 0) |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2619 set_waiting_for_input (&timeout); |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2620 |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2621 /* If status of something has changed, and no input is |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2622 available, notify the user of the change right away. After |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2623 this explicit check, we'll let the SIGCHLD handler zap |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2624 timeout to get our attention. */ |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2625 if (update_tick != process_tick && do_display) |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2626 { |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2627 SELECT_TYPE Atemp, Ctemp; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2628 |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2629 Atemp = input_wait_mask; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2630 Ctemp = connect_wait_mask; |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2631 EMACS_SET_SECS_USECS (timeout, 0, 0); |
|
18492
668304de6f92
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
18378
diff
changeset
|
2632 if ((select (max (max_process_desc, max_keyboard_desc) + 1, |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2633 &Atemp, |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2634 (num_pending_connects > 0 ? &Ctemp : (SELECT_TYPE *)0), |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2635 (SELECT_TYPE *)0, &timeout) |
|
11926
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
2636 <= 0)) |
|
2894
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2637 { |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2638 /* It's okay for us to do this and then continue with |
| 5534 | 2639 the loop, since timeout has already been zeroed out. */ |
|
2894
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2640 clear_waiting_for_input (); |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2641 status_notify (); |
|
646c5beae647
* process.c (wait_reading_process_input): Undo change of April
Jim Blandy <jimb@redhat.com>
parents:
2893
diff
changeset
|
2642 } |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2643 } |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2644 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2645 /* Don't wait for output from a non-running process. Just |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2646 read whatever data has already been received. */ |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2647 if (wait_proc != 0 && !NILP (wait_proc->raw_status_low)) |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2648 update_status (wait_proc); |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2649 if (wait_proc != 0 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2650 && ! EQ (wait_proc->status, Qrun) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2651 && ! EQ (wait_proc->status, Qconnect)) |
|
2893
4df57953d5d0
* process.c (wait_reading_process_input): Don't forget to call
Jim Blandy <jimb@redhat.com>
parents:
2887
diff
changeset
|
2652 { |
|
18946
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2653 int nread, total_nread = 0; |
|
18267
29c37882ee1f
(wait_reading_process_input): When exiting because
Richard M. Stallman <rms@gnu.org>
parents:
18230
diff
changeset
|
2654 |
|
2893
4df57953d5d0
* process.c (wait_reading_process_input): Don't forget to call
Jim Blandy <jimb@redhat.com>
parents:
2887
diff
changeset
|
2655 clear_waiting_for_input (); |
|
18267
29c37882ee1f
(wait_reading_process_input): When exiting because
Richard M. Stallman <rms@gnu.org>
parents:
18230
diff
changeset
|
2656 XSETPROCESS (proc, wait_proc); |
|
29c37882ee1f
(wait_reading_process_input): When exiting because
Richard M. Stallman <rms@gnu.org>
parents:
18230
diff
changeset
|
2657 |
|
29c37882ee1f
(wait_reading_process_input): When exiting because
Richard M. Stallman <rms@gnu.org>
parents:
18230
diff
changeset
|
2658 /* Read data from the process, until we exhaust it. */ |
|
25894
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2659 while (XINT (wait_proc->infd) >= 0) |
|
18946
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2660 { |
|
25894
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2661 nread = read_process_output (proc, XINT (wait_proc->infd)); |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2662 |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2663 if (nread == 0) |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2664 break; |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2665 |
|
18946
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2666 if (0 < nread) |
|
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2667 total_nread += nread; |
|
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2668 #ifdef EIO |
|
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2669 else if (nread == -1 && EIO == errno) |
|
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2670 break; |
|
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2671 #endif |
|
25894
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2672 #ifdef EAGAIN |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2673 else if (nread == -1 && EAGAIN == errno) |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2674 break; |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2675 #endif |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2676 #ifdef EWOULDBLOCK |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2677 else if (nread == -1 && EWOULDBLOCK == errno) |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2678 break; |
|
8bd3e6fbf42f
(wait_reading_process_input): When trying to suck
Gerd Moellmann <gerd@gnu.org>
parents:
25770
diff
changeset
|
2679 #endif |
|
18946
84b78d90cd45
(wait_reading_process_input): Initialize total_read.
Richard M. Stallman <rms@gnu.org>
parents:
18739
diff
changeset
|
2680 } |
|
18267
29c37882ee1f
(wait_reading_process_input): When exiting because
Richard M. Stallman <rms@gnu.org>
parents:
18230
diff
changeset
|
2681 if (total_nread > 0 && do_display) |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
2682 redisplay_preserve_echo_area (10); |
|
18267
29c37882ee1f
(wait_reading_process_input): When exiting because
Richard M. Stallman <rms@gnu.org>
parents:
18230
diff
changeset
|
2683 |
|
2893
4df57953d5d0
* process.c (wait_reading_process_input): Don't forget to call
Jim Blandy <jimb@redhat.com>
parents:
2887
diff
changeset
|
2684 break; |
|
4df57953d5d0
* process.c (wait_reading_process_input): Don't forget to call
Jim Blandy <jimb@redhat.com>
parents:
2887
diff
changeset
|
2685 } |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
2686 |
| 578 | 2687 /* Wait till there is something to do */ |
| 2688 | |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2689 if (!NILP (wait_for_cell)) |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2690 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2691 Available = non_process_wait_mask; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2692 check_connect = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2693 } |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
2694 else |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2695 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2696 if (! XINT (read_kbd)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2697 Available = non_keyboard_wait_mask; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2698 else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2699 Available = input_wait_mask; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2700 check_connect = (num_pending_connects > 0); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2701 } |
| 578 | 2702 |
| 765 | 2703 /* If frame size has changed or the window is newly mapped, |
| 648 | 2704 redisplay now, before we start to wait. There is a race |
| 2705 condition here; if a SIGIO arrives between now and the select | |
|
1655
05e84e6c7d04
Tue Dec 1 23:42:25 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1594
diff
changeset
|
2706 and indicates that a frame is trashed, the select may block |
|
05e84e6c7d04
Tue Dec 1 23:42:25 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
Jim Blandy <jimb@redhat.com>
parents:
1594
diff
changeset
|
2707 displaying a trashed screen. */ |
|
6429
1dbe24a029fd
(wait_reading_process_input, both versions): Don't call
Richard M. Stallman <rms@gnu.org>
parents:
6393
diff
changeset
|
2708 if (frame_garbaged && do_display) |
|
11728
affed1766d34
(wait_reading_process_input): Don't call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
11695
diff
changeset
|
2709 { |
|
affed1766d34
(wait_reading_process_input): Don't call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
11695
diff
changeset
|
2710 clear_waiting_for_input (); |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
2711 redisplay_preserve_echo_area (11); |
|
11728
affed1766d34
(wait_reading_process_input): Don't call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
11695
diff
changeset
|
2712 if (XINT (read_kbd) < 0) |
|
11744
52a2c8e81bb7
(wait_reading_process_input): Pass arg in new call to set_waiting_for_input.
Richard M. Stallman <rms@gnu.org>
parents:
11728
diff
changeset
|
2713 set_waiting_for_input (&timeout); |
|
11728
affed1766d34
(wait_reading_process_input): Don't call prepare_menu_bars.
Richard M. Stallman <rms@gnu.org>
parents:
11695
diff
changeset
|
2714 } |
| 648 | 2715 |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2716 no_avail = 0; |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
2717 if (XINT (read_kbd) && detect_input_pending ()) |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
2718 { |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
2719 nfds = 0; |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2720 no_avail = 1; |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
2721 } |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
2722 else |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2723 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2724 if (check_connect) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2725 Connecting = connect_wait_mask; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2726 nfds = select (max (max_process_desc, max_keyboard_desc) + 1, |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2727 &Available, |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2728 (check_connect ? &Connecting : (SELECT_TYPE *)0), |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2729 (SELECT_TYPE *)0, &timeout); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2730 } |
| 588 | 2731 |
| 578 | 2732 xerrno = errno; |
| 2733 | |
| 2734 /* Make C-g and alarm signals set flags again */ | |
| 2735 clear_waiting_for_input (); | |
| 2736 | |
| 2737 /* If we woke up due to SIGWINCH, actually change size now. */ | |
|
25356
5db69f7aadca
Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents:
25262
diff
changeset
|
2738 do_pending_window_change (0); |
| 578 | 2739 |
|
14458
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2740 if (time_limit && nfds == 0 && ! timeout_reduced_for_timers) |
|
2bb4652305c1
(wait_reading_process_input): If select times out,
Richard M. Stallman <rms@gnu.org>
parents:
14405
diff
changeset
|
2741 /* We wanted the full specified time, so return now. */ |
| 578 | 2742 break; |
| 2743 if (nfds < 0) | |
| 2744 { | |
| 2745 if (xerrno == EINTR) | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2746 no_avail = 1; |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
2747 #ifdef ultrix |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
2748 /* Ultrix select seems to return ENOMEM when it is |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
2749 interrupted. Treat it just like EINTR. Bleah. Note |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
2750 that we want to test for the "ultrix" CPP symbol, not |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
2751 "__ultrix__"; the latter is only defined under GCC, but |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
2752 not by DEC's bundled CC. -JimB */ |
|
1323
25b5b55a3916
* process.c (wait_reading_process_input): If the select returns
Jim Blandy <jimb@redhat.com>
parents:
1207
diff
changeset
|
2753 else if (xerrno == ENOMEM) |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2754 no_avail = 1; |
|
1323
25b5b55a3916
* process.c (wait_reading_process_input): If the select returns
Jim Blandy <jimb@redhat.com>
parents:
1207
diff
changeset
|
2755 #endif |
| 578 | 2756 #ifdef ALLIANT |
| 2757 /* This happens for no known reason on ALLIANT. | |
| 2758 I am guessing that this is the right response. -- RMS. */ | |
| 2759 else if (xerrno == EFAULT) | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2760 no_avail = 1; |
| 578 | 2761 #endif |
| 2762 else if (xerrno == EBADF) | |
| 2763 { | |
| 2764 #ifdef AIX | |
| 2765 /* AIX doesn't handle PTY closure the same way BSD does. On AIX, | |
| 2766 the child's closure of the pts gives the parent a SIGHUP, and | |
| 2767 the ptc file descriptor is automatically closed, | |
| 2768 yielding EBADF here or at select() call above. | |
| 2769 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF | |
| 5534 | 2770 in m/ibmrt-aix.h), and here we just ignore the select error. |
| 578 | 2771 Cleanup occurs c/o status_notify after SIGCLD. */ |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2772 no_avail = 1; /* Cannot depend on values returned */ |
| 578 | 2773 #else |
| 2774 abort (); | |
| 2775 #endif | |
| 2776 } | |
| 2777 else | |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
2778 error ("select error: %s", emacs_strerror (xerrno)); |
| 578 | 2779 } |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2780 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2781 if (no_avail) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2782 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2783 FD_ZERO (&Available); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2784 check_connect = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2785 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2786 |
|
2815
60f122cfe785
* process.c (wait_reading_process_input): If we're running
Jim Blandy <jimb@redhat.com>
parents:
2610
diff
changeset
|
2787 #if defined(sun) && !defined(USG5_4) |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2788 if (nfds > 0 && keyboard_bit_set (&Available) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2789 && interrupt_input) |
| 2830 | 2790 /* System sometimes fails to deliver SIGIO. |
| 2791 | |
| 2792 David J. Mackenzie says that Emacs doesn't compile under | |
| 2793 Solaris if this code is enabled, thus the USG5_4 in the CPP | |
| 2794 conditional. "I haven't noticed any ill effects so far. | |
| 2795 If you find a Solaris expert somewhere, they might know | |
| 2796 better." */ | |
| 578 | 2797 kill (getpid (), SIGIO); |
| 2798 #endif | |
| 2799 | |
|
18378
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2800 #if 0 /* When polling is used, interrupt_input is 0, |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2801 so get_input_pending should read the input. |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2802 So this should not be needed. */ |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2803 /* If we are using polling for input, |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2804 and we see input available, make it get read now. |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2805 Otherwise it might not actually get read for a second. |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2806 And on hpux, since we turn off polling in wait_reading_process_input, |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2807 it might never get read at all if we don't spend much time |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2808 outside of wait_reading_process_input. */ |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2809 if (XINT (read_kbd) && interrupt_input |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2810 && keyboard_bit_set (&Available) |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2811 && input_polling_used ()) |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2812 kill (getpid (), SIGALRM); |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2813 #endif |
|
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2814 |
| 578 | 2815 /* Check for keyboard input */ |
| 2816 /* If there is any, return immediately | |
| 2817 to give it higher priority than subprocesses */ | |
| 2818 | |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2819 if (XINT (read_kbd) != 0) |
| 14613 | 2820 { |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2821 int old_timers_run = timers_run; |
|
37465
f790d83ea743
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
37413
diff
changeset
|
2822 struct buffer *old_buffer = current_buffer; |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2823 int leave = 0; |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2824 |
|
14758
849458c13c0c
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14736
diff
changeset
|
2825 if (detect_input_pending_run_timers (do_display)) |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2826 { |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2827 swallow_events (do_display); |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2828 if (detect_input_pending_run_timers (do_display)) |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2829 leave = 1; |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2830 } |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2831 |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2832 /* If a timer has run, this might have changed buffers |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2833 an alike. Make read_key_sequence aware of that. */ |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2834 if (timers_run != old_timers_run |
|
37465
f790d83ea743
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
37413
diff
changeset
|
2835 && waiting_for_user_input_p == -1 |
|
f790d83ea743
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
37413
diff
changeset
|
2836 && old_buffer != current_buffer) |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2837 record_asynch_buffer_change (); |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2838 |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2839 if (leave) |
| 14613 | 2840 break; |
|
37398
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2841 } |
|
756d2f4e4058
(wait_reading_process_input): Call
Gerd Moellmann <gerd@gnu.org>
parents:
36659
diff
changeset
|
2842 |
|
18230
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2843 /* If there is unread keyboard input, also return. */ |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2844 if (XINT (read_kbd) != 0 |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2845 && requeued_events_pending_p ()) |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2846 break; |
|
2f1f942f25ca
(wait_reading_process_input): Return if unread events appear.
Richard M. Stallman <rms@gnu.org>
parents:
18183
diff
changeset
|
2847 |
|
19053
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2848 /* If we are not checking for keyboard input now, |
|
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2849 do process events (but don't run any timers). |
|
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2850 This is so that X events will be processed. |
|
18492
668304de6f92
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
18378
diff
changeset
|
2851 Otherwise they may have to wait until polling takes place. |
|
19053
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2852 That would causes delays in pasting selections, for example. |
|
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2853 |
|
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2854 (We used to do this only if wait_for_cell.) */ |
|
7b5642657857
(read_process_output): Don't call setup_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
18974
diff
changeset
|
2855 if (XINT (read_kbd) == 0 && detect_input_pending ()) |
|
15064
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2856 { |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2857 swallow_events (do_display); |
|
18492
668304de6f92
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
18378
diff
changeset
|
2858 #if 0 /* Exiting when read_kbd doesn't request that seems wrong, though. */ |
|
15064
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2859 if (detect_input_pending ()) |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2860 break; |
|
18492
668304de6f92
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
18378
diff
changeset
|
2861 #endif |
|
15064
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2862 } |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
2863 |
|
2200
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2864 /* Exit now if the cell we're waiting for became non-nil. */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2865 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) |
|
2200
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2866 break; |
|
5e58643bb169
(wait_reading_process_input): New option to wait
Richard M. Stallman <rms@gnu.org>
parents:
2120
diff
changeset
|
2867 |
| 621 | 2868 #ifdef SIGIO |
|
18378
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2869 /* If we think we have keyboard input waiting, but didn't get SIGIO, |
| 578 | 2870 go read it. This can happen with X on BSD after logging out. |
| 2871 In that case, there really is no input and no SIGIO, | |
| 2872 but select says there is input. */ | |
| 2873 | |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
2874 if (XINT (read_kbd) && interrupt_input |
|
18378
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
2875 && keyboard_bit_set (&Available)) |
|
14736
b17ec81a6294
(wait_reading_process_input): Use getpid when generating SIGIO.
Richard M. Stallman <rms@gnu.org>
parents:
14671
diff
changeset
|
2876 kill (getpid (), SIGIO); |
| 621 | 2877 #endif |
| 578 | 2878 |
| 2879 if (! wait_proc) | |
| 2880 got_some_input |= nfds > 0; | |
| 2881 | |
| 624 | 2882 /* If checking input just got us a size-change event from X, |
| 2883 obey it now if we should. */ | |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
2884 if (XINT (read_kbd) || ! NILP (wait_for_cell)) |
|
25356
5db69f7aadca
Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents:
25262
diff
changeset
|
2885 do_pending_window_change (0); |
| 624 | 2886 |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2887 /* Check for data from a process. */ |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2888 if (no_avail || nfds == 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2889 continue; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2890 |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2891 /* Really FIRST_PROC_DESC should be 0 on Unix, |
|
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2892 but this is safer in the short run. */ |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
2893 for (channel = 0; channel <= max_process_desc; channel++) |
| 578 | 2894 { |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
2895 if (FD_ISSET (channel, &Available) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
2896 && FD_ISSET (channel, &non_keyboard_wait_mask)) |
| 578 | 2897 { |
| 2898 int nread; | |
| 2899 | |
| 2900 /* If waiting for this channel, arrange to return as | |
| 2901 soon as no more input to be processed. No more | |
| 2902 waiting. */ | |
| 2903 if (wait_channel == channel) | |
| 2904 { | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
2905 wait_channel = -1; |
| 578 | 2906 time_limit = -1; |
| 2907 got_some_input = 1; | |
| 2908 } | |
| 2909 proc = chan_process[channel]; | |
| 2910 if (NILP (proc)) | |
| 2911 continue; | |
| 2912 | |
| 2913 /* Read data from the process, starting with our | |
| 2914 buffered-ahead character if we have one. */ | |
| 2915 | |
| 2916 nread = read_process_output (proc, channel); | |
| 2917 if (nread > 0) | |
| 2918 { | |
| 2919 /* Since read_process_output can run a filter, | |
| 2920 which can call accept-process-output, | |
| 2921 don't try to read from any other processes | |
| 2922 before doing the select again. */ | |
| 2923 FD_ZERO (&Available); | |
| 2924 | |
| 2925 if (do_display) | |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
2926 redisplay_preserve_echo_area (12); |
| 578 | 2927 } |
| 2928 #ifdef EWOULDBLOCK | |
| 2929 else if (nread == -1 && errno == EWOULDBLOCK) | |
| 2930 ; | |
|
15405
c27bb6e69e2d
(wait_reading_process_input): Move the O_NONBLOCK and
Richard M. Stallman <rms@gnu.org>
parents:
15368
diff
changeset
|
2931 #endif |
| 15406 | 2932 /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, |
| 2933 and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ | |
| 578 | 2934 #ifdef O_NONBLOCK |
| 2935 else if (nread == -1 && errno == EAGAIN) | |
| 2936 ; | |
| 2937 #else | |
| 2938 #ifdef O_NDELAY | |
| 2939 else if (nread == -1 && errno == EAGAIN) | |
| 2940 ; | |
| 2941 /* Note that we cannot distinguish between no input | |
| 2942 available now and a closed pipe. | |
| 2943 With luck, a closed pipe will be accompanied by | |
| 2944 subprocess termination and SIGCHLD. */ | |
| 2945 else if (nread == 0 && !NETCONN_P (proc)) | |
| 2946 ; | |
| 648 | 2947 #endif /* O_NDELAY */ |
| 2948 #endif /* O_NONBLOCK */ | |
| 578 | 2949 #ifdef HAVE_PTYS |
| 2950 /* On some OSs with ptys, when the process on one end of | |
| 2951 a pty exits, the other end gets an error reading with | |
| 2952 errno = EIO instead of getting an EOF (0 bytes read). | |
| 2953 Therefore, if we get an error reading and errno = | |
| 2954 EIO, just continue, because the child process has | |
| 2955 exited and should clean itself up soon (e.g. when we | |
|
23035
8d68b82a4d8c
(wait_reading_process_input): If a pty gives EIO,
Richard M. Stallman <rms@gnu.org>
parents:
22939
diff
changeset
|
2956 get a SIGCHLD). |
|
8d68b82a4d8c
(wait_reading_process_input): If a pty gives EIO,
Richard M. Stallman <rms@gnu.org>
parents:
22939
diff
changeset
|
2957 |
|
8d68b82a4d8c
(wait_reading_process_input): If a pty gives EIO,
Richard M. Stallman <rms@gnu.org>
parents:
22939
diff
changeset
|
2958 However, it has been known to happen that the SIGCHLD |
|
8d68b82a4d8c
(wait_reading_process_input): If a pty gives EIO,
Richard M. Stallman <rms@gnu.org>
parents:
22939
diff
changeset
|
2959 got lost. So raise the signl again just in case. |
|
8d68b82a4d8c
(wait_reading_process_input): If a pty gives EIO,
Richard M. Stallman <rms@gnu.org>
parents:
22939
diff
changeset
|
2960 It can't hurt. */ |
| 578 | 2961 else if (nread == -1 && errno == EIO) |
|
23035
8d68b82a4d8c
(wait_reading_process_input): If a pty gives EIO,
Richard M. Stallman <rms@gnu.org>
parents:
22939
diff
changeset
|
2962 kill (getpid (), SIGCHLD); |
| 648 | 2963 #endif /* HAVE_PTYS */ |
| 2964 /* If we can detect process termination, don't consider the process | |
| 2965 gone just because its pipe is closed. */ | |
| 578 | 2966 #ifdef SIGCHLD |
| 2967 else if (nread == 0 && !NETCONN_P (proc)) | |
| 2968 ; | |
| 2969 #endif | |
| 2970 else | |
| 2971 { | |
| 2972 /* Preserve status of processes already terminated. */ | |
| 2973 XSETINT (XPROCESS (proc)->tick, ++process_tick); | |
| 2974 deactivate_process (proc); | |
| 2975 if (!NILP (XPROCESS (proc)->raw_status_low)) | |
| 2976 update_status (XPROCESS (proc)); | |
| 2977 if (EQ (XPROCESS (proc)->status, Qrun)) | |
| 2978 XPROCESS (proc)->status | |
| 2979 = Fcons (Qexit, Fcons (make_number (256), Qnil)); | |
| 2980 } | |
| 2981 } | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2982 #ifdef NON_BLOCKING_CONNECT |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2983 if (check_connect && FD_ISSET (channel, &Connecting)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2984 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2985 struct Lisp_Process *p; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2986 struct sockaddr pname; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2987 socklen_t pnamelen = sizeof(pname); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2988 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2989 FD_CLR (channel, &connect_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2990 if (--num_pending_connects < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2991 abort (); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2992 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2993 proc = chan_process[channel]; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2994 if (NILP (proc)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2995 continue; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2996 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2997 p = XPROCESS (proc); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2998 |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
2999 #ifdef GNU_LINUX |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3000 /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3001 So only use it on systems where it is known to work. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3002 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3003 socklen_t xlen = sizeof(xerrno); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3004 if (getsockopt(channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3005 xerrno = errno; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3006 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3007 #else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3008 /* If connection failed, getpeername will fail. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3009 xerrno = 0; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3010 if (getpeername(channel, &pname, &pnamelen) < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3011 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3012 /* Obtain connect failure code through error slippage. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3013 char dummy; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3014 xerrno = errno; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3015 if (errno == ENOTCONN && read(channel, &dummy, 1) < 0) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3016 xerrno = errno; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3017 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3018 #endif |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3019 if (xerrno) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3020 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3021 XSETINT (p->tick, ++process_tick); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3022 p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil)); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3023 deactivate_process (proc); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3024 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3025 else |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3026 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3027 p->status = Qrun; |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3028 /* Execute the sentinel here. If we had relied on |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3029 status_notify to do it later, it will read input |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3030 from the process before calling the sentinel. */ |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3031 exec_sentinel (proc, build_string ("open\n")); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3032 if (!EQ (p->filter, Qt)) |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3033 { |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3034 FD_SET (XINT (p->infd), &input_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3035 FD_SET (XINT (p->infd), &non_keyboard_wait_mask); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3036 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3037 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3038 } |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
3039 #endif /* NON_BLOCKING_CONNECT */ |
| 648 | 3040 } /* end for each file descriptor */ |
| 3041 } /* end while exit conditions not met */ | |
| 3042 | |
|
8570
dd3dfde8f973
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
8390
diff
changeset
|
3043 waiting_for_user_input_p = 0; |
|
dd3dfde8f973
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
8390
diff
changeset
|
3044 |
| 648 | 3045 /* If calling from keyboard input, do not quit |
| 3046 since we want to return C-g as an input character. | |
| 3047 Otherwise, do pending quit if requested. */ | |
| 650 | 3048 if (XINT (read_kbd) >= 0) |
| 648 | 3049 { |
| 3050 /* Prevent input_pending from remaining set if we quit. */ | |
| 3051 clear_input_pending (); | |
| 3052 QUIT; | |
| 3053 } | |
|
15661
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3054 #ifdef hpux |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3055 /* AlainF 5-Jul-1996 |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3056 HP-UX 10.10 seems to have problems with signals coming in |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3057 Causes "poll: interrupted system call" messages when Emacs is run |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3058 in an X window |
|
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3059 Turn periodic alarms back on */ |
|
18378
22cd8d7dd5aa
(wait_reading_process_input): Don't check for
Richard M. Stallman <rms@gnu.org>
parents:
18329
diff
changeset
|
3060 start_polling (); |
|
15661
96debed5fb36
(wait_reading_process_input) [hpux]: Workaround for
Karl Heuer <kwzh@gnu.org>
parents:
15406
diff
changeset
|
3061 #endif |
|
25009
5733af0b62ce
(wait_reading_process_input): Show and hide busy
Gerd Moellmann <gerd@gnu.org>
parents:
24933
diff
changeset
|
3062 |
| 578 | 3063 return got_some_input; |
| 3064 } | |
| 3065 | |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3066 /* Given a list (FUNCTION ARGS...), apply FUNCTION to the ARGS. */ |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3067 |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3068 static Lisp_Object |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3069 read_process_output_call (fun_and_args) |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3070 Lisp_Object fun_and_args; |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3071 { |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
3072 return apply1 (XCAR (fun_and_args), XCDR (fun_and_args)); |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3073 } |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3074 |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3075 static Lisp_Object |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3076 read_process_output_error_handler (error) |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3077 Lisp_Object error; |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3078 { |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3079 cmd_error_internal (error, "error in process filter: "); |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3080 Vinhibit_quit = Qt; |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3081 update_echo_area (); |
|
11277
d4547e4b0aab
(read_process_output_error_handler)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
3082 Fsleep_for (make_number (2), Qnil); |
| 27558 | 3083 return Qt; |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3084 } |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3085 |
| 578 | 3086 /* Read pending output from the process channel, |
| 3087 starting with our buffered-ahead character if we have one. | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3088 Yield number of decoded characters read. |
| 578 | 3089 |
| 3090 This function reads at most 1024 characters. | |
| 3091 If you want to read all available subprocess output, | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3092 you must call it repeatedly until it returns zero. |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3093 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3094 The characters read are decoded according to PROC's coding-system |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3095 for decoding. */ |
| 578 | 3096 |
| 21514 | 3097 int |
| 578 | 3098 read_process_output (proc, channel) |
| 3099 Lisp_Object proc; | |
| 3100 register int channel; | |
| 3101 { | |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3102 register int nchars, nbytes; |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3103 char *chars; |
| 578 | 3104 register Lisp_Object outstream; |
| 3105 register struct buffer *old = current_buffer; | |
| 3106 register struct Lisp_Process *p = XPROCESS (proc); | |
| 3107 register int opoint; | |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
3108 struct coding_system *coding = proc_decode_coding_system[channel]; |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3109 int carryover = XINT (p->decoding_carryover); |
| 578 | 3110 |
| 3111 #ifdef VMS | |
| 3112 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); | |
| 3113 | |
| 3114 vs = get_vms_process_pointer (p->pid); | |
| 3115 if (vs) | |
| 3116 { | |
| 3117 if (!vs->iosb[0]) | |
|
25248
f0fc8443bdbb
(Fopen_network_stream): Use getaddrinfo.
Karl Heuer <kwzh@gnu.org>
parents:
25129
diff
changeset
|
3118 return (0); /* Really weird if it does this */ |
| 578 | 3119 if (!(vs->iosb[0] & 1)) |
| 3120 return -1; /* I/O error */ | |
| 3121 } | |
| 3122 else | |
| 3123 error ("Could not get VMS process pointer"); | |
| 3124 chars = vs->inputBuffer; | |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3125 nbytes = clean_vms_buffer (chars, vs->iosb[1]); |
|
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3126 if (nbytes <= 0) |
| 578 | 3127 { |
| 3128 start_vms_process_read (vs); /* Crank up the next read on the process */ | |
| 3129 return 1; /* Nothing worth printing, say we got 1 */ | |
| 3130 } | |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3131 if (carryover > 0) |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3132 { |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3133 /* The data carried over in the previous decoding (which are at |
|
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3134 the tail of decoding buffer) should be prepended to the new |
|
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3135 data read to decode all together. */ |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3136 chars = (char *) alloca (nbytes + carryover); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3137 bcopy (XSTRING (p->decoding_buf)->data, buf, carryover); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3138 bcopy (vs->inputBuffer, chars + carryover, nbytes); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3139 } |
| 578 | 3140 #else /* not VMS */ |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3141 chars = (char *) alloca (carryover + 1024); |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3142 if (carryover) |
|
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3143 /* See the comment above. */ |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3144 bcopy (XSTRING (p->decoding_buf)->data, chars, carryover); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3145 |
| 578 | 3146 if (proc_buffered_char[channel] < 0) |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3147 nbytes = emacs_read (channel, chars + carryover, 1024 - carryover); |
| 578 | 3148 else |
| 3149 { | |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3150 chars[carryover] = proc_buffered_char[channel]; |
| 578 | 3151 proc_buffered_char[channel] = -1; |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3152 nbytes = emacs_read (channel, chars + carryover + 1, 1023 - carryover); |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3153 if (nbytes < 0) |
|
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3154 nbytes = 1; |
| 578 | 3155 else |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3156 nbytes = nbytes + 1; |
| 578 | 3157 } |
| 3158 #endif /* not VMS */ | |
| 3159 | |
|
22523
b02a5ea8cf93
(read_process_output): Handle carryover correctly.
Kenichi Handa <handa@m17n.org>
parents:
22019
diff
changeset
|
3160 XSETINT (p->decoding_carryover, 0); |
|
b02a5ea8cf93
(read_process_output): Handle carryover correctly.
Kenichi Handa <handa@m17n.org>
parents:
22019
diff
changeset
|
3161 |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3162 /* At this point, NBYTES holds number of bytes just received |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3163 (including the one in proc_buffered_char[channel]). */ |
|
23879
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
3164 if (nbytes <= 0) |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
3165 { |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
3166 if (nbytes < 0 || coding->mode & CODING_MODE_LAST_BLOCK) |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
3167 return nbytes; |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
3168 coding->mode |= CODING_MODE_LAST_BLOCK; |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
3169 } |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3170 |
|
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3171 /* Now set NBYTES how many bytes we must decode. */ |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3172 nbytes += carryover; |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
3173 |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3174 /* Read and dispose of the process output. */ |
| 578 | 3175 outstream = p->filter; |
| 3176 if (!NILP (outstream)) | |
| 3177 { | |
| 3178 /* We inhibit quit here instead of just catching it so that | |
| 3179 hitting ^G when a filter happens to be running won't screw | |
| 3180 it up. */ | |
| 3181 int count = specpdl_ptr - specpdl; | |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3182 Lisp_Object odeactivate; |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3183 Lisp_Object obuffer, okeymap; |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3184 Lisp_Object text; |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3185 int outer_running_asynch_code = running_asynch_code; |
|
23460
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
3186 int waiting = waiting_for_user_input_p; |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3187 |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3188 /* No need to gcpro these, because all we do with them later |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3189 is test them for EQness, and none of them should be a string. */ |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3190 odeactivate = Vdeactivate_mark; |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3191 XSETBUFFER (obuffer, current_buffer); |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3192 okeymap = current_buffer->keymap; |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3193 |
| 578 | 3194 specbind (Qinhibit_quit, Qt); |
|
8231
5226ed89c1a6
(Qlast_nonmenu_event): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8063
diff
changeset
|
3195 specbind (Qlast_nonmenu_event, Qt); |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
3196 |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3197 /* In case we get recursively called, |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3198 and we already saved the match data nonrecursively, |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3199 save the same match data in safely recursive fashion. */ |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3200 if (outer_running_asynch_code) |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3201 { |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3202 Lisp_Object tem; |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3203 /* Don't clobber the CURRENT match data, either! */ |
|
16728
309a750fd5c0
(read_process_output, exec_sentinel):
Richard M. Stallman <rms@gnu.org>
parents:
16718
diff
changeset
|
3204 tem = Fmatch_data (Qnil, Qnil); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3205 restore_match_data (); |
|
21177
73f8ae8312c8
(exec_sentinel, read_process_output): Fstore_match_data => Fset_match_data.
Richard M. Stallman <rms@gnu.org>
parents:
21049
diff
changeset
|
3206 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); |
|
73f8ae8312c8
(exec_sentinel, read_process_output): Fstore_match_data => Fset_match_data.
Richard M. Stallman <rms@gnu.org>
parents:
21049
diff
changeset
|
3207 Fset_match_data (tem); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3208 } |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3209 |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3210 /* For speed, if a search happens within this code, |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3211 save the match data in a special nonrecursive fashion. */ |
|
10032
f689803caa92
Added code for automatically saving and restoring the match data
Francesco Potort? <pot@gnu.org>
parents:
9969
diff
changeset
|
3212 running_asynch_code = 1; |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3213 |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3214 text = decode_coding_string (make_unibyte_string (chars, nbytes), |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3215 coding, 0); |
|
31136
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3216 if (NILP (buffer_defaults.enable_multibyte_characters)) |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3217 /* We had better return unibyte string. */ |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3218 text = string_make_unibyte (text); |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3219 |
| 30582 | 3220 Vlast_coding_system_used = coding->symbol; |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3221 /* A new coding system might be found. */ |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3222 if (!EQ (p->decode_coding_system, coding->symbol)) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3223 { |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3224 p->decode_coding_system = coding->symbol; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3225 |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3226 /* Don't call setup_coding_system for |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3227 proc_decode_coding_system[channel] here. It is done in |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3228 detect_coding called via decode_coding above. */ |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3229 |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3230 /* If a coding system for encoding is not yet decided, we set |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3231 it as the same as coding-system for decoding. |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3232 |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3233 But, before doing that we must check if |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3234 proc_encode_coding_system[p->outfd] surely points to a |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3235 valid memory because p->outfd will be changed once EOF is |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3236 sent to the process. */ |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3237 if (NILP (p->encode_coding_system) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3238 && proc_encode_coding_system[XINT (p->outfd)]) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3239 { |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3240 p->encode_coding_system = coding->symbol; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3241 setup_coding_system (coding->symbol, |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3242 proc_encode_coding_system[XINT (p->outfd)]); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3243 } |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3244 } |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3245 |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3246 carryover = nbytes - coding->consumed; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3247 bcopy (chars + coding->consumed, XSTRING (p->decoding_buf)->data, |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3248 carryover); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3249 XSETINT (p->decoding_carryover, carryover); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3250 nbytes = STRING_BYTES (XSTRING (text)); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3251 nchars = XSTRING (text)->size; |
|
34647
1898b3c996ff
(read_process_output): Don't run a filter if the code
Kenichi Handa <handa@m17n.org>
parents:
34352
diff
changeset
|
3252 if (nbytes > 0) |
|
1898b3c996ff
(read_process_output): Don't run a filter if the code
Kenichi Handa <handa@m17n.org>
parents:
34352
diff
changeset
|
3253 internal_condition_case_1 (read_process_output_call, |
|
1898b3c996ff
(read_process_output): Don't run a filter if the code
Kenichi Handa <handa@m17n.org>
parents:
34352
diff
changeset
|
3254 Fcons (outstream, |
|
1898b3c996ff
(read_process_output): Don't run a filter if the code
Kenichi Handa <handa@m17n.org>
parents:
34352
diff
changeset
|
3255 Fcons (proc, Fcons (text, Qnil))), |
|
1898b3c996ff
(read_process_output): Don't run a filter if the code
Kenichi Handa <handa@m17n.org>
parents:
34352
diff
changeset
|
3256 !NILP (Vdebug_on_error) ? Qnil : Qerror, |
|
1898b3c996ff
(read_process_output): Don't run a filter if the code
Kenichi Handa <handa@m17n.org>
parents:
34352
diff
changeset
|
3257 read_process_output_error_handler); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3258 |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3259 /* If we saved the match data nonrecursively, restore it now. */ |
|
10032
f689803caa92
Added code for automatically saving and restoring the match data
Francesco Potort? <pot@gnu.org>
parents:
9969
diff
changeset
|
3260 restore_match_data (); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
3261 running_asynch_code = outer_running_asynch_code; |
| 578 | 3262 |
|
3666
c7ff787b096f
(read_process_output): Don't deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3608
diff
changeset
|
3263 /* Handling the process output should not deactivate the mark. */ |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3264 Vdeactivate_mark = odeactivate; |
|
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3265 |
|
23460
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
3266 /* Restore waiting_for_user_input_p as it was |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
3267 when we were called, in case the filter clobbered it. */ |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
3268 waiting_for_user_input_p = waiting; |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
3269 |
|
12808
4db1f387e85f
(read_process_output, exec_sentinel): Call
Richard M. Stallman <rms@gnu.org>
parents:
12749
diff
changeset
|
3270 #if 0 /* Call record_asynch_buffer_change unconditionally, |
|
4db1f387e85f
(read_process_output, exec_sentinel): Call
Richard M. Stallman <rms@gnu.org>
parents:
12749
diff
changeset
|
3271 because we might have changed minor modes or other things |
|
4db1f387e85f
(read_process_output, exec_sentinel): Call
Richard M. Stallman <rms@gnu.org>
parents:
12749
diff
changeset
|
3272 that affect key bindings. */ |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3273 if (! EQ (Fcurrent_buffer (), obuffer) |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
3274 || ! EQ (current_buffer->keymap, okeymap)) |
|
12808
4db1f387e85f
(read_process_output, exec_sentinel): Call
Richard M. Stallman <rms@gnu.org>
parents:
12749
diff
changeset
|
3275 #endif |
|
13159
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
3276 /* But do it only if the caller is actually going to read events. |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
3277 Otherwise there's no need to make him wake up, and it could |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
3278 cause trouble (for example it would make Fsit_for return). */ |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
3279 if (waiting_for_user_input_p == -1) |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
3280 record_asynch_buffer_change (); |
|
6748
b1cde622fa65
(read_process_output): If buffer changes, record that fact.
Karl Heuer <kwzh@gnu.org>
parents:
6569
diff
changeset
|
3281 |
| 578 | 3282 #ifdef VMS |
| 3283 start_vms_process_read (vs); | |
| 3284 #endif | |
|
5561
fd7524d61a8d
(read_process_output): Supply second arg to unbind_to.
Richard M. Stallman <rms@gnu.org>
parents:
5548
diff
changeset
|
3285 unbind_to (count, Qnil); |
| 578 | 3286 return nchars; |
| 3287 } | |
| 3288 | |
| 3289 /* If no filter, write into buffer if it isn't dead. */ | |
| 3290 if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name)) | |
| 3291 { | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3292 Lisp_Object old_read_only; |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3293 int old_begv, old_zv; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3294 int old_begv_byte, old_zv_byte; |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3295 Lisp_Object odeactivate; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3296 int before, before_byte; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3297 int opoint_byte; |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3298 Lisp_Object text; |
|
34352
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3299 struct buffer *b; |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3300 |
|
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3301 odeactivate = Vdeactivate_mark; |
| 578 | 3302 |
| 3303 Fset_buffer (p->buffer); | |
|
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15895
diff
changeset
|
3304 opoint = PT; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3305 opoint_byte = PT_BYTE; |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3306 old_read_only = current_buffer->read_only; |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3307 old_begv = BEGV; |
|
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3308 old_zv = ZV; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3309 old_begv_byte = BEGV_BYTE; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3310 old_zv_byte = ZV_BYTE; |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3311 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3312 current_buffer->read_only = Qnil; |
| 578 | 3313 |
| 3314 /* Insert new output into buffer | |
| 3315 at the current end-of-output marker, | |
| 3316 thus preserving logical ordering of input and output. */ | |
| 3317 if (XMARKER (p->mark)->buffer) | |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3318 SET_PT_BOTH (clip_to_bounds (BEGV, marker_position (p->mark), ZV), |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3319 clip_to_bounds (BEGV_BYTE, marker_byte_position (p->mark), |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3320 ZV_BYTE)); |
| 578 | 3321 else |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3322 SET_PT_BOTH (ZV, ZV_BYTE); |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3323 before = PT; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3324 before_byte = PT_BYTE; |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3325 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3326 /* If the output marker is outside of the visible region, save |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3327 the restriction and widen. */ |
|
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15895
diff
changeset
|
3328 if (! (BEGV <= PT && PT <= ZV)) |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3329 Fwiden (); |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3330 |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3331 text = decode_coding_string (make_unibyte_string (chars, nbytes), |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3332 coding, 0); |
| 30582 | 3333 Vlast_coding_system_used = coding->symbol; |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3334 /* A new coding system might be found. See the comment in the |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3335 similar code in the previous `if' block. */ |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3336 if (!EQ (p->decode_coding_system, coding->symbol)) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3337 { |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3338 p->decode_coding_system = coding->symbol; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3339 if (NILP (p->encode_coding_system) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3340 && proc_encode_coding_system[XINT (p->outfd)]) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3341 { |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3342 p->encode_coding_system = coding->symbol; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3343 setup_coding_system (coding->symbol, |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3344 proc_encode_coding_system[XINT (p->outfd)]); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3345 } |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3346 } |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3347 carryover = nbytes - coding->consumed; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3348 bcopy (chars + coding->consumed, XSTRING (p->decoding_buf)->data, |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3349 carryover); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3350 XSETINT (p->decoding_carryover, carryover); |
|
31419
bd258f4dc0fa
(read_process_output): Before inserting the decoded
Kenichi Handa <handa@m17n.org>
parents:
31136
diff
changeset
|
3351 /* Adjust the multibyteness of TEXT to that of the buffer. */ |
|
bd258f4dc0fa
(read_process_output): Before inserting the decoded
Kenichi Handa <handa@m17n.org>
parents:
31136
diff
changeset
|
3352 if (NILP (current_buffer->enable_multibyte_characters) |
|
bd258f4dc0fa
(read_process_output): Before inserting the decoded
Kenichi Handa <handa@m17n.org>
parents:
31136
diff
changeset
|
3353 != ! STRING_MULTIBYTE (text)) |
|
bd258f4dc0fa
(read_process_output): Before inserting the decoded
Kenichi Handa <handa@m17n.org>
parents:
31136
diff
changeset
|
3354 text = (STRING_MULTIBYTE (text) |
|
32395
11b8c07e5fed
(read_process_output): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
32371
diff
changeset
|
3355 ? Fstring_as_unibyte (text) |
|
11b8c07e5fed
(read_process_output): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
32371
diff
changeset
|
3356 : Fstring_as_multibyte (text)); |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3357 nbytes = STRING_BYTES (XSTRING (text)); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3358 nchars = XSTRING (text)->size; |
|
32395
11b8c07e5fed
(read_process_output): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
32371
diff
changeset
|
3359 /* Insert before markers in case we are inserting where |
|
11b8c07e5fed
(read_process_output): Cancel previous change.
Kenichi Handa <handa@m17n.org>
parents:
32371
diff
changeset
|
3360 the buffer's mark is, and the user's next command is Meta-y. */ |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3361 insert_from_string_before_markers (text, 0, 0, nchars, nbytes, 0); |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
3362 |
|
34352
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3363 /* Make sure the process marker's position is valid when the |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3364 process buffer is changed in the signal_after_change above. |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3365 W3 is known to do that. */ |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3366 if (BUFFERP (p->buffer) |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3367 && (b = XBUFFER (p->buffer), b != current_buffer)) |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3368 set_marker_both (p->mark, p->buffer, BUF_PT (b), BUF_PT_BYTE (b)); |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3369 else |
|
642fb6c53a10
(read_process_output): Make sure the process marker's
Gerd Moellmann <gerd@gnu.org>
parents:
32864
diff
changeset
|
3370 set_marker_both (p->mark, p->buffer, PT, PT_BYTE); |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3371 |
| 578 | 3372 update_mode_lines++; |
| 3373 | |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3374 /* Make sure opoint and the old restrictions |
|
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3375 float ahead of any new text just as point would. */ |
|
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3376 if (opoint >= before) |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3377 { |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3378 opoint += PT - before; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3379 opoint_byte += PT_BYTE - before_byte; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3380 } |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3381 if (old_begv > before) |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3382 { |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3383 old_begv += PT - before; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3384 old_begv_byte += PT_BYTE - before_byte; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3385 } |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3386 if (old_zv >= before) |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3387 { |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3388 old_zv += PT - before; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3389 old_zv_byte += PT_BYTE - before_byte; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3390 } |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3391 |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3392 /* If the restriction isn't what it should be, set it. */ |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3393 if (old_begv != BEGV || old_zv != ZV) |
|
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
3394 Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3395 |
|
3666
c7ff787b096f
(read_process_output): Don't deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3608
diff
changeset
|
3396 /* Handling the process output should not deactivate the mark. */ |
|
3510
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3397 Vdeactivate_mark = odeactivate; |
|
b4a552ca4e99
(read_process_output): Deactivate the mark.
Richard M. Stallman <rms@gnu.org>
parents:
3238
diff
changeset
|
3398 |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3399 current_buffer->read_only = old_read_only; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3400 SET_PT_BOTH (opoint, opoint_byte); |
| 578 | 3401 set_buffer_internal (old); |
| 3402 } | |
| 3403 #ifdef VMS | |
| 3404 start_vms_process_read (vs); | |
| 3405 #endif | |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3406 return nbytes; |
| 578 | 3407 } |
| 3408 | |
| 3409 DEFUN ("waiting-for-user-input-p", Fwaiting_for_user_input_p, Swaiting_for_user_input_p, | |
| 3410 0, 0, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3411 doc: /* Returns non-nil if emacs is waiting for input from the user. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3412 This is intended for use by asynchronous process output filters and sentinels. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3413 () |
| 578 | 3414 { |
|
7352
ef89b78c1a92
(wait_reading_process_input): Don't call prepare_menu_bars
Richard M. Stallman <rms@gnu.org>
parents:
7266
diff
changeset
|
3415 return (waiting_for_user_input_p ? Qt : Qnil); |
| 578 | 3416 } |
| 3417 | |
| 3418 /* Sending data to subprocess */ | |
| 3419 | |
| 3420 jmp_buf send_process_frame; | |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3421 Lisp_Object process_sent_to; |
| 578 | 3422 |
| 3423 SIGTYPE | |
| 3424 send_process_trap () | |
| 3425 { | |
| 3426 #ifdef BSD4_1 | |
| 3427 sigrelse (SIGPIPE); | |
| 3428 sigrelse (SIGALRM); | |
| 3429 #endif /* BSD4_1 */ | |
| 3430 longjmp (send_process_frame, 1); | |
| 3431 } | |
| 3432 | |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3433 /* Send some data to process PROC. |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3434 BUF is the beginning of the data; LEN is the number of characters. |
|
32864
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3435 OBJECT is the Lisp object that the data comes from. If OBJECT is |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3436 nil or t, it means that the data comes from C string. |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3437 |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3438 If OBJECT is not nil, the data is encoded by PROC's coding-system |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3439 for encoding before it is sent. |
|
28157
336858b2b11a
(send_process): Add a hint that the function
Gerd Moellmann <gerd@gnu.org>
parents:
28012
diff
changeset
|
3440 |
|
336858b2b11a
(send_process): Add a hint that the function
Gerd Moellmann <gerd@gnu.org>
parents:
28012
diff
changeset
|
3441 This function can evaluate Lisp code and can garbage collect. */ |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3442 |
| 21514 | 3443 void |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3444 send_process (proc, buf, len, object) |
|
11926
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
3445 volatile Lisp_Object proc; |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3446 unsigned char *volatile buf; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3447 volatile int len; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3448 volatile Lisp_Object object; |
| 578 | 3449 { |
|
11926
40d7e6f04ebe
(create_process, send_process): Add volatile qualifiers.
Karl Heuer <kwzh@gnu.org>
parents:
11845
diff
changeset
|
3450 /* Use volatile to protect variables from being clobbered by longjmp. */ |
| 578 | 3451 int rv; |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3452 struct coding_system *coding; |
|
15895
85112cca0b22
(send_process): GCPRO object.
Richard M. Stallman <rms@gnu.org>
parents:
15717
diff
changeset
|
3453 struct gcpro gcpro1; |
|
85112cca0b22
(send_process): GCPRO object.
Richard M. Stallman <rms@gnu.org>
parents:
15717
diff
changeset
|
3454 |
|
85112cca0b22
(send_process): GCPRO object.
Richard M. Stallman <rms@gnu.org>
parents:
15717
diff
changeset
|
3455 GCPRO1 (object); |
| 578 | 3456 |
| 3457 #ifdef VMS | |
| 3458 struct Lisp_Process *p = XPROCESS (proc); | |
| 3459 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); | |
| 3460 #endif /* VMS */ | |
| 3461 | |
| 3462 if (! NILP (XPROCESS (proc)->raw_status_low)) | |
| 3463 update_status (XPROCESS (proc)); | |
| 3464 if (! EQ (XPROCESS (proc)->status, Qrun)) | |
|
28012
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3465 error ("Process %s not running", |
|
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3466 XSTRING (XPROCESS (proc)->name)->data); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3467 if (XINT (XPROCESS (proc)->outfd) < 0) |
|
28012
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3468 error ("Output file descriptor of %s is closed", |
|
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3469 XSTRING (XPROCESS (proc)->name)->data); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3470 |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
3471 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; |
|
20433
a43789debf48
(read_process_output): Fix previous change, i.e, if
Kenichi Handa <handa@m17n.org>
parents:
20428
diff
changeset
|
3472 Vlast_coding_system_used = coding->symbol; |
|
a43789debf48
(read_process_output): Fix previous change, i.e, if
Kenichi Handa <handa@m17n.org>
parents:
20428
diff
changeset
|
3473 |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3474 if ((STRINGP (object) && STRING_MULTIBYTE (object)) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3475 || (BUFFERP (object) |
|
32864
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3476 && !NILP (XBUFFER (object)->enable_multibyte_characters)) |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3477 || EQ (object, Qt)) |
|
31136
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3478 { |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3479 if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system)) |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3480 /* The coding system for encoding was changed to raw-text |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3481 because we sent a unibyte text previously. Now we are |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3482 sending a multibyte text, thus we must encode it by the |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3483 original coding system specified for the current |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3484 process. */ |
|
42600
93254645e03b
(send_process): Set src_multibyte to 1 after the call
Eli Zaretskii <eliz@gnu.org>
parents:
41969
diff
changeset
|
3485 setup_coding_system (XPROCESS (proc)->encode_coding_system, coding); |
|
93254645e03b
(send_process): Set src_multibyte to 1 after the call
Eli Zaretskii <eliz@gnu.org>
parents:
41969
diff
changeset
|
3486 /* src_multibyte should be set to 1 _after_ a call to |
|
93254645e03b
(send_process): Set src_multibyte to 1 after the call
Eli Zaretskii <eliz@gnu.org>
parents:
41969
diff
changeset
|
3487 setup_coding_system, since it resets src_multibyte to |
|
93254645e03b
(send_process): Set src_multibyte to 1 after the call
Eli Zaretskii <eliz@gnu.org>
parents:
41969
diff
changeset
|
3488 zero. */ |
|
93254645e03b
(send_process): Set src_multibyte to 1 after the call
Eli Zaretskii <eliz@gnu.org>
parents:
41969
diff
changeset
|
3489 coding->src_multibyte = 1; |
|
31136
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3490 } |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3491 else |
|
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3492 { |
|
32864
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3493 /* For sending a unibyte text, character code conversion should |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3494 not take place but EOL conversion should. So, setup raw-text |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3495 or one of the subsidiary if we have not yet done it. */ |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3496 if (coding->type != coding_type_raw_text) |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3497 { |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3498 if (CODING_REQUIRE_FLUSHING (coding)) |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3499 { |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3500 /* But, before changing the coding, we must flush out data. */ |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3501 coding->mode |= CODING_MODE_LAST_BLOCK; |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3502 send_process (proc, "", 0, Qt); |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3503 } |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3504 coding->src_multibyte = 0; |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3505 setup_raw_text_coding_system (coding); |
|
21acd0c60f5d
(send_process): If OBJECT is t, it means that the data
Kenichi Handa <handa@m17n.org>
parents:
32395
diff
changeset
|
3506 } |
|
31136
d1344c992a9a
(create_process): Don't setup raw-text coding here.
Kenichi Handa <handa@m17n.org>
parents:
31099
diff
changeset
|
3507 } |
|
29017
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
3508 coding->dst_multibyte = 0; |
|
8f10362eb5ff
(Fstart_process): GCPRO current_dir before calling
Kenichi Handa <handa@m17n.org>
parents:
28157
diff
changeset
|
3509 |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3510 if (CODING_REQUIRE_ENCODING (coding)) |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3511 { |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3512 int require = encoding_buffer_size (coding, len); |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3513 int from_byte = -1, from = -1, to = -1; |
|
18585
64184009811b
(send_process): Make buf and temp_buf `unsigned char *'.
Richard M. Stallman <rms@gnu.org>
parents:
18540
diff
changeset
|
3514 unsigned char *temp_buf = NULL; |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3515 |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3516 if (BUFFERP (object)) |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3517 { |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3518 from_byte = BUF_PTR_BYTE_POS (XBUFFER (object), buf); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3519 from = buf_bytepos_to_charpos (XBUFFER (object), from_byte); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3520 to = buf_bytepos_to_charpos (XBUFFER (object), from_byte + len); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3521 } |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3522 else if (STRINGP (object)) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3523 { |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3524 from_byte = buf - XSTRING (object)->data; |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3525 from = string_byte_to_char (object, from_byte); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3526 to = string_byte_to_char (object, from_byte + len); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3527 } |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3528 |
|
39429
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3529 if (coding->composing != COMPOSITION_DISABLED) |
|
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3530 { |
|
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3531 if (from_byte >= 0) |
|
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3532 coding_save_composition (coding, from, to, object); |
|
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3533 else |
|
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3534 coding->composing = COMPOSITION_DISABLED; |
|
9de129194439
(send_process): Disable composition if from_byte < 0.
Gerd Moellmann <gerd@gnu.org>
parents:
39406
diff
changeset
|
3535 } |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3536 |
|
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21177
diff
changeset
|
3537 if (STRING_BYTES (XSTRING (XPROCESS (proc)->encoding_buf)) < require) |
|
30580
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3538 XPROCESS (proc)->encoding_buf = make_uninit_string (require); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3539 |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3540 if (from_byte >= 0) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3541 buf = (BUFFERP (object) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3542 ? BUF_BYTE_ADDRESS (XBUFFER (object), from_byte) |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3543 : XSTRING (object)->data + from_byte); |
|
5d92193ed196
(read_process_output): Big simplification. Handle
Kenichi Handa <handa@m17n.org>
parents:
29921
diff
changeset
|
3544 |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3545 object = XPROCESS (proc)->encoding_buf; |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3546 encode_coding (coding, (char *) buf, XSTRING (object)->data, |
|
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21177
diff
changeset
|
3547 len, STRING_BYTES (XSTRING (object))); |
|
20715
5e983ddb85c9
(Fstart_process): Use raw-text instead of emacs-mule
Kenichi Handa <handa@m17n.org>
parents:
20708
diff
changeset
|
3548 len = coding->produced; |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3549 buf = XSTRING (object)->data; |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3550 if (temp_buf) |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3551 xfree (temp_buf); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
3552 } |
| 578 | 3553 |
| 3554 #ifdef VMS | |
| 3555 vs = get_vms_process_pointer (p->pid); | |
| 3556 if (vs == 0) | |
| 3557 error ("Could not find this process: %x", p->pid); | |
| 3558 else if (write_to_vms_process (vs, buf, len)) | |
| 3559 ; | |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3560 #else /* not VMS */ |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3561 |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3562 if (pty_max_bytes == 0) |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3563 { |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3564 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON) |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3565 pty_max_bytes = fpathconf (XFASTINT (XPROCESS (proc)->outfd), |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3566 _PC_MAX_CANON); |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3567 if (pty_max_bytes < 0) |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3568 pty_max_bytes = 250; |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3569 #else |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3570 pty_max_bytes = 250; |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3571 #endif |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3572 /* Deduct one, to leave space for the eof. */ |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3573 pty_max_bytes--; |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3574 } |
|
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3575 |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3576 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3577 CFLAGS="-g -O": The value of the parameter `proc' is clobbered |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3578 when returning with longjmp despite being declared volatile. */ |
| 578 | 3579 if (!setjmp (send_process_frame)) |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3580 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3581 process_sent_to = proc; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3582 while (len > 0) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3583 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3584 int this = len; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3585 SIGTYPE (*old_sigpipe)(); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3586 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3587 /* Decide how much data we can send in one batch. |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3588 Long lines need to be split into multiple batches. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3589 if (!NILP (XPROCESS (proc)->pty_flag)) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3590 { |
|
39812
66e0816837a8
Update calls to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39429
diff
changeset
|
3591 /* Starting this at zero is always correct when not the first |
|
66e0816837a8
Update calls to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
39429
diff
changeset
|
3592 iteration because the previous iteration ended by sending C-d. |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3593 It may not be correct for the first iteration |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3594 if a partial line was sent in a separate send_process call. |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3595 If that proves worth handling, we need to save linepos |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3596 in the process object. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3597 int linepos = 0; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3598 unsigned char *ptr = (unsigned char *) buf; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3599 unsigned char *end = (unsigned char *) buf + len; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3600 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3601 /* Scan through this text for a line that is too long. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3602 while (ptr != end && linepos < pty_max_bytes) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3603 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3604 if (*ptr == '\n') |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3605 linepos = 0; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3606 else |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3607 linepos++; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3608 ptr++; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3609 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3610 /* If we found one, break the line there |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3611 and put in a C-d to force the buffer through. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3612 this = ptr - buf; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3613 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3614 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3615 /* Send this batch, using one or more write calls. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3616 while (this > 0) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3617 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3618 old_sigpipe = (SIGTYPE (*) ()) signal (SIGPIPE, send_process_trap); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3619 rv = emacs_write (XINT (XPROCESS (proc)->outfd), |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3620 (char *) buf, this); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3621 signal (SIGPIPE, old_sigpipe); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3622 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3623 if (rv < 0) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3624 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3625 if (0 |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3626 #ifdef EWOULDBLOCK |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3627 || errno == EWOULDBLOCK |
| 6158 | 3628 #endif |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3629 #ifdef EAGAIN |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3630 || errno == EAGAIN |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3631 #endif |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3632 ) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3633 /* Buffer is full. Wait, accepting input; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3634 that may allow the program |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3635 to finish doing output and read more. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3636 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3637 Lisp_Object zero; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3638 int offset = 0; |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3639 |
|
27705
2c53eb482802
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
Gerd Moellmann <gerd@gnu.org>
parents:
27669
diff
changeset
|
3640 #ifdef BROKEN_PTY_READ_AFTER_EAGAIN |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3641 /* A gross hack to work around a bug in FreeBSD. |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3642 In the following sequence, read(2) returns |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3643 bogus data: |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3644 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3645 write(2) 1022 bytes |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3646 write(2) 954 bytes, get EAGAIN |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3647 read(2) 1024 bytes in process_read_output |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3648 read(2) 11 bytes in process_read_output |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3649 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3650 That is, read(2) returns more bytes than have |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3651 ever been written successfully. The 1033 bytes |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3652 read are the 1022 bytes written successfully |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3653 after processing (for example with CRs added if |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3654 the terminal is set up that way which it is |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3655 here). The same bytes will be seen again in a |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3656 later read(2), without the CRs. */ |
|
27705
2c53eb482802
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
Gerd Moellmann <gerd@gnu.org>
parents:
27669
diff
changeset
|
3657 |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3658 if (errno == EAGAIN) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3659 { |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3660 int flags = FWRITE; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3661 ioctl (XINT (XPROCESS (proc)->outfd), TIOCFLUSH, |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3662 &flags); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3663 } |
|
27705
2c53eb482802
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
Gerd Moellmann <gerd@gnu.org>
parents:
27669
diff
changeset
|
3664 #endif /* BROKEN_PTY_READ_AFTER_EAGAIN */ |
|
2c53eb482802
(send_process) [BROKEN_PTY_READ_AFTER_EAGAIN]:
Gerd Moellmann <gerd@gnu.org>
parents:
27669
diff
changeset
|
3665 |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3666 /* Running filters might relocate buffers or strings. |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3667 Arrange to relocate BUF. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3668 if (BUFFERP (object)) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3669 offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3670 else if (STRINGP (object)) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3671 offset = buf - XSTRING (object)->data; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3672 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3673 XSETFASTINT (zero, 0); |
|
16718
ea26040865cb
(send_process) [EMACS_HAS_USECS]:
Richard M. Stallman <rms@gnu.org>
parents:
16644
diff
changeset
|
3674 #ifdef EMACS_HAS_USECS |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3675 wait_reading_process_input (0, 20000, zero, 0); |
|
16718
ea26040865cb
(send_process) [EMACS_HAS_USECS]:
Richard M. Stallman <rms@gnu.org>
parents:
16644
diff
changeset
|
3676 #else |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3677 wait_reading_process_input (1, 0, zero, 0); |
|
16718
ea26040865cb
(send_process) [EMACS_HAS_USECS]:
Richard M. Stallman <rms@gnu.org>
parents:
16644
diff
changeset
|
3678 #endif |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3679 |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3680 if (BUFFERP (object)) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3681 buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3682 else if (STRINGP (object)) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3683 buf = offset + XSTRING (object)->data; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3684 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3685 rv = 0; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3686 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3687 else |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3688 /* This is a real error. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3689 report_file_error ("writing to process", Fcons (proc, Qnil)); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3690 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3691 buf += rv; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3692 len -= rv; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3693 this -= rv; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3694 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3695 |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3696 /* If we sent just part of the string, put in an EOF |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3697 to force it through, before we send the rest. */ |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3698 if (len > 0) |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3699 Fprocess_send_eof (proc); |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3700 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3701 } |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3702 #endif /* not VMS */ |
| 578 | 3703 else |
| 3704 { | |
|
31806
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3705 #ifndef VMS |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3706 proc = process_sent_to; |
|
b148beb59511
(process_sent_to): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
31419
diff
changeset
|
3707 #endif |
| 578 | 3708 XPROCESS (proc)->raw_status_low = Qnil; |
| 3709 XPROCESS (proc)->raw_status_high = Qnil; | |
| 3710 XPROCESS (proc)->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); | |
| 3711 XSETINT (XPROCESS (proc)->tick, ++process_tick); | |
| 3712 deactivate_process (proc); | |
| 3713 #ifdef VMS | |
|
28012
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3714 error ("Error writing to process %s; closed it", |
|
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3715 XSTRING (XPROCESS (proc)->name)->data); |
| 578 | 3716 #else |
|
28012
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3717 error ("SIGPIPE raised on process %s; closed it", |
|
9c8bcd7e4a4f
(send_process): Remove local variable `procname' that
Gerd Moellmann <gerd@gnu.org>
parents:
27861
diff
changeset
|
3718 XSTRING (XPROCESS (proc)->name)->data); |
| 578 | 3719 #endif |
| 3720 } | |
|
15895
85112cca0b22
(send_process): GCPRO object.
Richard M. Stallman <rms@gnu.org>
parents:
15717
diff
changeset
|
3721 |
|
85112cca0b22
(send_process): GCPRO object.
Richard M. Stallman <rms@gnu.org>
parents:
15717
diff
changeset
|
3722 UNGCPRO; |
| 578 | 3723 } |
| 3724 | |
| 3725 DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3726 3, 3, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3727 doc: /* Send current contents of region as input to PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3728 PROCESS may be a process, a buffer, the name of a process or buffer, or |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3729 nil, indicating the current buffer's process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3730 Called from program, takes three arguments, PROCESS, START and END. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3731 If the region is more than 500 characters long, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3732 it is sent in several bunches. This may happen even for shorter regions. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3733 Output from processes can arrive in between bunches. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3734 (process, start, end) |
| 578 | 3735 Lisp_Object process, start, end; |
| 3736 { | |
| 3737 Lisp_Object proc; | |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3738 int start1, end1; |
| 578 | 3739 |
| 3740 proc = get_process (process); | |
| 3741 validate_region (&start, &end); | |
| 3742 | |
| 3743 if (XINT (start) < GPT && XINT (end) > GPT) | |
|
18739
60f002497be1
(Fprocess_send_region): Convert move_gap argument to int.
Richard M. Stallman <rms@gnu.org>
parents:
18708
diff
changeset
|
3744 move_gap (XINT (start)); |
| 578 | 3745 |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3746 start1 = CHAR_TO_BYTE (XINT (start)); |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3747 end1 = CHAR_TO_BYTE (XINT (end)); |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
3748 send_process (proc, BYTE_POS_ADDR (start1), end1 - start1, |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3749 Fcurrent_buffer ()); |
| 578 | 3750 |
| 3751 return Qnil; | |
| 3752 } | |
| 3753 | |
| 3754 DEFUN ("process-send-string", Fprocess_send_string, Sprocess_send_string, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3755 2, 2, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3756 doc: /* Send PROCESS the contents of STRING as input. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3757 PROCESS may be a process, a buffer, the name of a process or buffer, or |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3758 nil, indicating the current buffer's process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3759 If STRING is more than 500 characters long, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3760 it is sent in several bunches. This may happen even for shorter strings. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3761 Output from processes can arrive in between bunches. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3762 (process, string) |
| 578 | 3763 Lisp_Object process, string; |
| 3764 { | |
| 3765 Lisp_Object proc; | |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
3766 CHECK_STRING (string); |
| 578 | 3767 proc = get_process (process); |
|
20594
6e5a5afbe628
(read_process_output): Use insert_1_both.
Richard M. Stallman <rms@gnu.org>
parents:
20551
diff
changeset
|
3768 send_process (proc, XSTRING (string)->data, |
|
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
21177
diff
changeset
|
3769 STRING_BYTES (XSTRING (string)), string); |
| 578 | 3770 return Qnil; |
| 3771 } | |
| 3772 | |
|
24352
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3773 DEFUN ("process-running-child-p", Fprocess_running_child_p, |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3774 Sprocess_running_child_p, 0, 1, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3775 doc: /* Return t if PROCESS has given the terminal to a child. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3776 If the operating system does not make it possible to find out, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3777 return t unconditionally. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
3778 (process) |
|
24352
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3779 Lisp_Object process; |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3780 { |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3781 /* Initialize in case ioctl doesn't exist or gives an error, |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3782 in a way that will cause returning t. */ |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3783 int gid = 0; |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3784 Lisp_Object proc; |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3785 struct Lisp_Process *p; |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3786 |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3787 proc = get_process (process); |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3788 p = XPROCESS (proc); |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3789 |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3790 if (!EQ (p->childp, Qt)) |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3791 error ("Process %s is not a subprocess", |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3792 XSTRING (p->name)->data); |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3793 if (XINT (p->infd) < 0) |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3794 error ("Process %s is not active", |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3795 XSTRING (p->name)->data); |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3796 |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3797 #ifdef TIOCGPGRP |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3798 if (!NILP (p->subtty)) |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3799 ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3800 else |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3801 ioctl (XINT (p->infd), TIOCGPGRP, &gid); |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3802 #endif /* defined (TIOCGPGRP ) */ |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3803 |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3804 if (gid == XFASTINT (p->pid)) |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3805 return Qnil; |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3806 return Qt; |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3807 } |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3808 |
| 578 | 3809 /* send a signal number SIGNO to PROCESS. |
|
24352
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3810 If CURRENT_GROUP is t, that means send to the process group |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3811 that currently owns the terminal being used to communicate with PROCESS. |
| 578 | 3812 This is used for various commands in shell mode. |
|
24352
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3813 If CURRENT_GROUP is lambda, that means send to the process group |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3814 that currently owns the terminal, but only if it is NOT the shell itself. |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3815 |
| 578 | 3816 If NOMSG is zero, insert signal-announcements into process's buffers |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3817 right away. |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3818 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3819 If we can, we try to signal PROCESS by sending control characters |
|
7220
a33eb16cab9d
(Fopen_network_stream): Retry the connect if EADDRINUSE. Ignore EISCONN.
Richard M. Stallman <rms@gnu.org>
parents:
7157
diff
changeset
|
3820 down the pty. This allows us to signal inferiors who have changed |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3821 their uid, for which killpg would return an EPERM error. */ |
| 578 | 3822 |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3823 static void |
| 578 | 3824 process_send_signal (process, signo, current_group, nomsg) |
| 3825 Lisp_Object process; | |
| 3826 int signo; | |
| 3827 Lisp_Object current_group; | |
| 3828 int nomsg; | |
| 3829 { | |
| 3830 Lisp_Object proc; | |
| 3831 register struct Lisp_Process *p; | |
| 3832 int gid; | |
| 3833 int no_pgrp = 0; | |
| 3834 | |
| 3835 proc = get_process (process); | |
| 3836 p = XPROCESS (proc); | |
| 3837 | |
| 3838 if (!EQ (p->childp, Qt)) | |
| 3839 error ("Process %s is not a subprocess", | |
| 3840 XSTRING (p->name)->data); | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3841 if (XINT (p->infd) < 0) |
| 578 | 3842 error ("Process %s is not active", |
| 3843 XSTRING (p->name)->data); | |
| 3844 | |
| 3845 if (NILP (p->pty_flag)) | |
| 3846 current_group = Qnil; | |
| 3847 | |
| 3848 /* If we are using pgrps, get a pgrp number and make it negative. */ | |
| 3849 if (!NILP (current_group)) | |
| 3850 { | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3851 #ifdef SIGNALS_VIA_CHARACTERS |
| 578 | 3852 /* If possible, send signals to the entire pgrp |
| 3853 by sending an input character to it. */ | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3854 |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3855 /* TERMIOS is the latest and bestest, and seems most likely to |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3856 work. If the system has it, use it. */ |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3857 #ifdef HAVE_TERMIOS |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3858 struct termios t; |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3859 |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3860 switch (signo) |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3861 { |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3862 case SIGINT: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3863 tcgetattr (XINT (p->infd), &t); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3864 send_process (proc, &t.c_cc[VINTR], 1, Qnil); |
|
2120
fc3cdca22f8d
* process.c (process_send_signal): In the TERMIOS code for sending
Jim Blandy <jimb@redhat.com>
parents:
1925
diff
changeset
|
3865 return; |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3866 |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3867 case SIGQUIT: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3868 tcgetattr (XINT (p->infd), &t); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3869 send_process (proc, &t.c_cc[VQUIT], 1, Qnil); |
|
2120
fc3cdca22f8d
* process.c (process_send_signal): In the TERMIOS code for sending
Jim Blandy <jimb@redhat.com>
parents:
1925
diff
changeset
|
3870 return; |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3871 |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3872 case SIGTSTP: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3873 tcgetattr (XINT (p->infd), &t); |
|
7414
33e5afbb62bf
(process_send_signal): If PREFER_VSUSP, use VSUSP instead of VSWTCH.
Richard M. Stallman <rms@gnu.org>
parents:
7352
diff
changeset
|
3874 #if defined (VSWTCH) && !defined (PREFER_VSUSP) |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3875 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3876 #else |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3877 send_process (proc, &t.c_cc[VSUSP], 1, Qnil); |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3878 #endif |
|
2120
fc3cdca22f8d
* process.c (process_send_signal): In the TERMIOS code for sending
Jim Blandy <jimb@redhat.com>
parents:
1925
diff
changeset
|
3879 return; |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3880 } |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3881 |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3882 #else /* ! HAVE_TERMIOS */ |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3883 |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3884 /* On Berkeley descendants, the following IOCTL's retrieve the |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3885 current control characters. */ |
| 578 | 3886 #if defined (TIOCGLTC) && defined (TIOCGETC) |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3887 |
| 578 | 3888 struct tchars c; |
| 3889 struct ltchars lc; | |
| 3890 | |
| 3891 switch (signo) | |
| 3892 { | |
| 3893 case SIGINT: | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3894 ioctl (XINT (p->infd), TIOCGETC, &c); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3895 send_process (proc, &c.t_intrc, 1, Qnil); |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3896 return; |
| 578 | 3897 case SIGQUIT: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3898 ioctl (XINT (p->infd), TIOCGETC, &c); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3899 send_process (proc, &c.t_quitc, 1, Qnil); |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3900 return; |
|
1012
a48ed1d416dd
* process.c (process_send_signal): Don't send SIGTSTP if the
Jim Blandy <jimb@redhat.com>
parents:
849
diff
changeset
|
3901 #ifdef SIGTSTP |
| 578 | 3902 case SIGTSTP: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3903 ioctl (XINT (p->infd), TIOCGLTC, &lc); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3904 send_process (proc, &lc.t_suspc, 1, Qnil); |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3905 return; |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3906 #endif /* ! defined (SIGTSTP) */ |
| 578 | 3907 } |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3908 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3909 #else /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3910 |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3911 /* On SYSV descendants, the TCGETA ioctl retrieves the current control |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3912 characters. */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3913 #ifdef TCGETA |
| 578 | 3914 struct termio t; |
| 3915 switch (signo) | |
| 3916 { | |
| 3917 case SIGINT: | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3918 ioctl (XINT (p->infd), TCGETA, &t); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3919 send_process (proc, &t.c_cc[VINTR], 1, Qnil); |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3920 return; |
| 578 | 3921 case SIGQUIT: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3922 ioctl (XINT (p->infd), TCGETA, &t); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3923 send_process (proc, &t.c_cc[VQUIT], 1, Qnil); |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3924 return; |
|
1569
52a69b6a8f96
* process.c [SYSV]: Don't include <termios.h>, <termio.h>, or
Jim Blandy <jimb@redhat.com>
parents:
1522
diff
changeset
|
3925 #ifdef SIGTSTP |
| 578 | 3926 case SIGTSTP: |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3927 ioctl (XINT (p->infd), TCGETA, &t); |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3928 send_process (proc, &t.c_cc[VSWTCH], 1, Qnil); |
|
1522
19ccf004b172
* process.c: (status_convert): Declare this to return a
Jim Blandy <jimb@redhat.com>
parents:
1323
diff
changeset
|
3929 return; |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3930 #endif /* ! defined (SIGTSTP) */ |
| 578 | 3931 } |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3932 #else /* ! defined (TCGETA) */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3933 Your configuration files are messed up. |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3934 /* If your system configuration files define SIGNALS_VIA_CHARACTERS, |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3935 you'd better be using one of the alternatives above! */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3936 #endif /* ! defined (TCGETA) */ |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3937 #endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */ |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
3938 #endif /* ! defined HAVE_TERMIOS */ |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3939 #endif /* ! defined (SIGNALS_VIA_CHARACTERS) */ |
| 849 | 3940 |
| 3941 #ifdef TIOCGPGRP | |
| 578 | 3942 /* Get the pgrp using the tty itself, if we have that. |
| 3943 Otherwise, use the pty to get the pgrp. | |
| 3944 On pfa systems, saka@pfu.fujitsu.co.JP writes: | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3945 "TIOCGPGRP symbol defined in sys/ioctl.h at E50. |
|
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3946 But, TIOCGPGRP does not work on E50 ;-P works fine on E60" |
| 578 | 3947 His patch indicates that if TIOCGPGRP returns an error, then |
| 3948 we should just assume that p->pid is also the process group id. */ | |
| 3949 { | |
| 3950 int err; | |
| 3951 | |
| 3952 if (!NILP (p->subtty)) | |
| 3953 err = ioctl (XFASTINT (p->subtty), TIOCGPGRP, &gid); | |
| 3954 else | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
3955 err = ioctl (XINT (p->infd), TIOCGPGRP, &gid); |
| 578 | 3956 |
| 3957 #ifdef pfa | |
| 3958 if (err == -1) | |
| 3959 gid = - XFASTINT (p->pid); | |
| 849 | 3960 #endif /* ! defined (pfa) */ |
| 578 | 3961 } |
| 3962 if (gid == -1) | |
| 3963 no_pgrp = 1; | |
| 3964 else | |
| 3965 gid = - gid; | |
|
1594
b476a97ad17e
* systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents:
1569
diff
changeset
|
3966 #else /* ! defined (TIOCGPGRP ) */ |
| 849 | 3967 /* Can't select pgrps on this system, so we know that |
| 3968 the child itself heads the pgrp. */ | |
| 3969 gid = - XFASTINT (p->pid); | |
| 3970 #endif /* ! defined (TIOCGPGRP ) */ | |
|
24352
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3971 |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3972 /* If current_group is lambda, and the shell owns the terminal, |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3973 don't send any signal. */ |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3974 if (EQ (current_group, Qlambda) && gid == - XFASTINT (p->pid)) |
|
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
3975 return; |
| 578 | 3976 } |
| 3977 else | |
| 3978 gid = - XFASTINT (p->pid); | |
| 3979 | |
| 3980 switch (signo) | |
| 3981 { | |
| 3982 #ifdef SIGCONT | |
| 3983 case SIGCONT: | |
| 3984 p->raw_status_low = Qnil; | |
| 3985 p->raw_status_high = Qnil; | |
| 3986 p->status = Qrun; | |
| 3987 XSETINT (p->tick, ++process_tick); | |
| 3988 if (!nomsg) | |
| 3989 status_notify (); | |
| 3990 break; | |
| 849 | 3991 #endif /* ! defined (SIGCONT) */ |
| 578 | 3992 case SIGINT: |
| 3993 #ifdef VMS | |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3994 send_process (proc, "\003", 1, Qnil); /* ^C */ |
| 578 | 3995 goto whoosh; |
| 3996 #endif | |
| 3997 case SIGQUIT: | |
| 3998 #ifdef VMS | |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
3999 send_process (proc, "\031", 1, Qnil); /* ^Y */ |
| 578 | 4000 goto whoosh; |
| 4001 #endif | |
| 4002 case SIGKILL: | |
| 4003 #ifdef VMS | |
| 4004 sys$forcex (&(XFASTINT (p->pid)), 0, 1); | |
| 4005 whoosh: | |
| 4006 #endif | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
4007 flush_pending_output (XINT (p->infd)); |
| 578 | 4008 break; |
| 4009 } | |
| 4010 | |
| 4011 /* If we don't have process groups, send the signal to the immediate | |
| 4012 subprocess. That isn't really right, but it's better than any | |
| 4013 obvious alternative. */ | |
| 4014 if (no_pgrp) | |
| 4015 { | |
| 4016 kill (XFASTINT (p->pid), signo); | |
| 4017 return; | |
| 4018 } | |
| 4019 | |
| 4020 /* gid may be a pid, or minus a pgrp's number */ | |
| 4021 #ifdef TIOCSIGSEND | |
| 4022 if (!NILP (current_group)) | |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
4023 ioctl (XINT (p->infd), TIOCSIGSEND, signo); |
| 578 | 4024 else |
| 4025 { | |
| 4026 gid = - XFASTINT (p->pid); | |
| 4027 kill (gid, signo); | |
| 4028 } | |
| 849 | 4029 #else /* ! defined (TIOCSIGSEND) */ |
| 578 | 4030 EMACS_KILLPG (-gid, signo); |
| 849 | 4031 #endif /* ! defined (TIOCSIGSEND) */ |
| 578 | 4032 } |
| 4033 | |
| 4034 DEFUN ("interrupt-process", Finterrupt_process, Sinterrupt_process, 0, 2, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4035 doc: /* Interrupt process PROCESS. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4036 PROCESS may be a process, a buffer, or the name of a process or buffer. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4037 nil or no arg means current buffer's process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4038 Second arg CURRENT-GROUP non-nil means send signal to |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4039 the current process-group of the process's controlling terminal |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4040 rather than to the process's own process group. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4041 If the process is a shell, this means interrupt current subjob |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4042 rather than the shell. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4043 |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4044 If CURRENT-GROUP is `lambda', and if the shell owns the terminal, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4045 don't send the signal. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4046 (process, current_group) |
| 578 | 4047 Lisp_Object process, current_group; |
| 4048 { | |
| 4049 process_send_signal (process, SIGINT, current_group, 0); | |
| 4050 return process; | |
| 4051 } | |
| 4052 | |
| 4053 DEFUN ("kill-process", Fkill_process, Skill_process, 0, 2, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4054 doc: /* Kill process PROCESS. May be process or name of one. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4055 See function `interrupt-process' for more details on usage. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4056 (process, current_group) |
| 578 | 4057 Lisp_Object process, current_group; |
| 4058 { | |
| 4059 process_send_signal (process, SIGKILL, current_group, 0); | |
| 4060 return process; | |
| 4061 } | |
| 4062 | |
| 4063 DEFUN ("quit-process", Fquit_process, Squit_process, 0, 2, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4064 doc: /* Send QUIT signal to process PROCESS. May be process or name of one. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4065 See function `interrupt-process' for more details on usage. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4066 (process, current_group) |
| 578 | 4067 Lisp_Object process, current_group; |
| 4068 { | |
| 4069 process_send_signal (process, SIGQUIT, current_group, 0); | |
| 4070 return process; | |
| 4071 } | |
| 4072 | |
| 4073 DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4074 doc: /* Stop process PROCESS. May be process or name of one. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4075 See function `interrupt-process' for more details on usage. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4076 (process, current_group) |
| 578 | 4077 Lisp_Object process, current_group; |
| 4078 { | |
| 4079 #ifndef SIGTSTP | |
| 4080 error ("no SIGTSTP support"); | |
| 4081 #else | |
| 4082 process_send_signal (process, SIGTSTP, current_group, 0); | |
| 4083 #endif | |
| 4084 return process; | |
| 4085 } | |
| 4086 | |
| 4087 DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4088 doc: /* Continue process PROCESS. May be process or name of one. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4089 See function `interrupt-process' for more details on usage. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4090 (process, current_group) |
| 578 | 4091 Lisp_Object process, current_group; |
| 4092 { | |
| 4093 #ifdef SIGCONT | |
| 4094 process_send_signal (process, SIGCONT, current_group, 0); | |
| 4095 #else | |
| 4096 error ("no SIGCONT support"); | |
| 4097 #endif | |
| 4098 return process; | |
| 4099 } | |
| 4100 | |
| 4101 DEFUN ("signal-process", Fsignal_process, Ssignal_process, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4102 2, 2, "nProcess number: \nnSignal code: ", |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4103 doc: /* Send the process with process id PID the signal with code SIGCODE. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4104 PID must be an integer. The process need not be a child of this Emacs. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4105 SIGCODE may be an integer, or a symbol whose name is a signal name. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4106 (pid, sigcode) |
|
11144
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4107 Lisp_Object pid, sigcode; |
| 578 | 4108 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
4109 CHECK_NUMBER (pid); |
|
11144
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4110 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4111 #define handle_signal(NAME, VALUE) \ |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4112 else if (!strcmp (name, NAME)) \ |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4113 XSETINT (sigcode, VALUE) |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4114 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4115 if (INTEGERP (sigcode)) |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4116 ; |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4117 else |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4118 { |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4119 unsigned char *name; |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4120 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
4121 CHECK_SYMBOL (sigcode); |
|
11144
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4122 name = XSYMBOL (sigcode)->name->data; |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4123 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4124 if (0) |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4125 ; |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4126 #ifdef SIGHUP |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4127 handle_signal ("SIGHUP", SIGHUP); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4128 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4129 #ifdef SIGINT |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4130 handle_signal ("SIGINT", SIGINT); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4131 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4132 #ifdef SIGQUIT |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4133 handle_signal ("SIGQUIT", SIGQUIT); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4134 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4135 #ifdef SIGILL |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4136 handle_signal ("SIGILL", SIGILL); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4137 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4138 #ifdef SIGABRT |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4139 handle_signal ("SIGABRT", SIGABRT); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4140 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4141 #ifdef SIGEMT |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4142 handle_signal ("SIGEMT", SIGEMT); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4143 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4144 #ifdef SIGKILL |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4145 handle_signal ("SIGKILL", SIGKILL); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4146 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4147 #ifdef SIGFPE |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4148 handle_signal ("SIGFPE", SIGFPE); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4149 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4150 #ifdef SIGBUS |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4151 handle_signal ("SIGBUS", SIGBUS); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4152 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4153 #ifdef SIGSEGV |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4154 handle_signal ("SIGSEGV", SIGSEGV); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4155 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4156 #ifdef SIGSYS |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4157 handle_signal ("SIGSYS", SIGSYS); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4158 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4159 #ifdef SIGPIPE |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4160 handle_signal ("SIGPIPE", SIGPIPE); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4161 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4162 #ifdef SIGALRM |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4163 handle_signal ("SIGALRM", SIGALRM); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4164 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4165 #ifdef SIGTERM |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4166 handle_signal ("SIGTERM", SIGTERM); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4167 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4168 #ifdef SIGURG |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4169 handle_signal ("SIGURG", SIGURG); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4170 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4171 #ifdef SIGSTOP |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4172 handle_signal ("SIGSTOP", SIGSTOP); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4173 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4174 #ifdef SIGTSTP |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4175 handle_signal ("SIGTSTP", SIGTSTP); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4176 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4177 #ifdef SIGCONT |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4178 handle_signal ("SIGCONT", SIGCONT); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4179 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4180 #ifdef SIGCHLD |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4181 handle_signal ("SIGCHLD", SIGCHLD); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4182 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4183 #ifdef SIGTTIN |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4184 handle_signal ("SIGTTIN", SIGTTIN); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4185 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4186 #ifdef SIGTTOU |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4187 handle_signal ("SIGTTOU", SIGTTOU); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4188 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4189 #ifdef SIGIO |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4190 handle_signal ("SIGIO", SIGIO); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4191 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4192 #ifdef SIGXCPU |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4193 handle_signal ("SIGXCPU", SIGXCPU); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4194 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4195 #ifdef SIGXFSZ |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4196 handle_signal ("SIGXFSZ", SIGXFSZ); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4197 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4198 #ifdef SIGVTALRM |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4199 handle_signal ("SIGVTALRM", SIGVTALRM); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4200 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4201 #ifdef SIGPROF |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4202 handle_signal ("SIGPROF", SIGPROF); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4203 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4204 #ifdef SIGWINCH |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4205 handle_signal ("SIGWINCH", SIGWINCH); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4206 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4207 #ifdef SIGINFO |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4208 handle_signal ("SIGINFO", SIGINFO); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4209 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4210 #ifdef SIGUSR1 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4211 handle_signal ("SIGUSR1", SIGUSR1); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4212 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4213 #ifdef SIGUSR2 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4214 handle_signal ("SIGUSR2", SIGUSR2); |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4215 #endif |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4216 else |
|
11148
117b32676686
(Fsignal_process): SIGCODE is a symbol, not a string.
Karl Heuer <kwzh@gnu.org>
parents:
11144
diff
changeset
|
4217 error ("Undefined signal name %s", name); |
|
11144
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4218 } |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4219 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4220 #undef handle_signal |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4221 |
|
c2b689aeb934
(Fsignal_process): Allow signal names as well as numbers.
Richard M. Stallman <rms@gnu.org>
parents:
10914
diff
changeset
|
4222 return make_number (kill (XINT (pid), XINT (sigcode))); |
| 578 | 4223 } |
| 4224 | |
| 4225 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4226 doc: /* Make PROCESS see end-of-file in its input. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4227 EOF comes after any text already sent to it. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4228 PROCESS may be a process, a buffer, the name of a process or buffer, or |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4229 nil, indicating the current buffer's process. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4230 If PROCESS is a network connection, or is a process communicating |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4231 through a pipe (as opposed to a pty), then you cannot send any more |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4232 text to PROCESS after you call this function. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4233 (process) |
| 578 | 4234 Lisp_Object process; |
| 4235 { | |
| 4236 Lisp_Object proc; | |
|
23879
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4237 struct coding_system *coding; |
| 578 | 4238 |
| 4239 proc = get_process (process); | |
|
23879
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4240 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; |
|
2221
7edc78402205
(Fprocess_send_eof): Make sure proc is running.
Richard M. Stallman <rms@gnu.org>
parents:
2200
diff
changeset
|
4241 |
|
7edc78402205
(Fprocess_send_eof): Make sure proc is running.
Richard M. Stallman <rms@gnu.org>
parents:
2200
diff
changeset
|
4242 /* Make sure the process is really alive. */ |
|
7edc78402205
(Fprocess_send_eof): Make sure proc is running.
Richard M. Stallman <rms@gnu.org>
parents:
2200
diff
changeset
|
4243 if (! NILP (XPROCESS (proc)->raw_status_low)) |
|
7edc78402205
(Fprocess_send_eof): Make sure proc is running.
Richard M. Stallman <rms@gnu.org>
parents:
2200
diff
changeset
|
4244 update_status (XPROCESS (proc)); |
|
7edc78402205
(Fprocess_send_eof): Make sure proc is running.
Richard M. Stallman <rms@gnu.org>
parents:
2200
diff
changeset
|
4245 if (! EQ (XPROCESS (proc)->status, Qrun)) |
|
2222
d81c60c5f9ce
Fix typo in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
2221
diff
changeset
|
4246 error ("Process %s not running", XSTRING (XPROCESS (proc)->name)->data); |
|
2221
7edc78402205
(Fprocess_send_eof): Make sure proc is running.
Richard M. Stallman <rms@gnu.org>
parents:
2200
diff
changeset
|
4247 |
|
23879
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4248 if (CODING_REQUIRE_FLUSHING (coding)) |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4249 { |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4250 coding->mode |= CODING_MODE_LAST_BLOCK; |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4251 send_process (proc, "", 0, Qnil); |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4252 } |
|
18e5d1cfa74b
(read_process_output): If NBYTES is zero and
Kenichi Handa <handa@m17n.org>
parents:
23762
diff
changeset
|
4253 |
| 578 | 4254 #ifdef VMS |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
4255 send_process (proc, "\032", 1, Qnil); /* ^z */ |
| 578 | 4256 #else |
| 4257 if (!NILP (XPROCESS (proc)->pty_flag)) | |
|
8063
30861f2f4f84
(send_process): Major rewrite.
Richard M. Stallman <rms@gnu.org>
parents:
7937
diff
changeset
|
4258 send_process (proc, "\004", 1, Qnil); |
| 578 | 4259 else |
| 4260 { | |
|
22939
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4261 int old_outfd, new_outfd; |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4262 |
|
18329
ddaafa596bf5
(Fprocess_send_eof): Prooperly conditionalize prev. change.
Richard M. Stallman <rms@gnu.org>
parents:
18328
diff
changeset
|
4263 #ifdef HAVE_SHUTDOWN |
|
18328
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4264 /* If this is a network connection, or socketpair is used |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4265 for communication with the subprocess, call shutdown to cause EOF. |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4266 (In some old system, shutdown to socketpair doesn't work. |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4267 Then we just can't win.) */ |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4268 if (NILP (XPROCESS (proc)->pid) |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4269 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4270 shutdown (XINT (XPROCESS (proc)->outfd), 1); |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4271 /* In case of socketpair, outfd == infd, so don't close it. */ |
|
0295bbed3c39
(Fprocess_send_eof): Use shutdown, if it's a socket.
Richard M. Stallman <rms@gnu.org>
parents:
18292
diff
changeset
|
4272 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4273 emacs_close (XINT (XPROCESS (proc)->outfd)); |
|
18329
ddaafa596bf5
(Fprocess_send_eof): Prooperly conditionalize prev. change.
Richard M. Stallman <rms@gnu.org>
parents:
18328
diff
changeset
|
4274 #else /* not HAVE_SHUTDOWN */ |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4275 emacs_close (XINT (XPROCESS (proc)->outfd)); |
|
18329
ddaafa596bf5
(Fprocess_send_eof): Prooperly conditionalize prev. change.
Richard M. Stallman <rms@gnu.org>
parents:
18328
diff
changeset
|
4276 #endif /* not HAVE_SHUTDOWN */ |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4277 new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); |
|
22939
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4278 old_outfd = XINT (XPROCESS (proc)->outfd); |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4279 |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4280 if (!proc_encode_coding_system[new_outfd]) |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4281 proc_encode_coding_system[new_outfd] |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4282 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4283 bcopy (proc_encode_coding_system[old_outfd], |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4284 proc_encode_coding_system[new_outfd], |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4285 sizeof (struct coding_system)); |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4286 bzero (proc_encode_coding_system[old_outfd], |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4287 sizeof (struct coding_system)); |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4288 |
|
572895549f80
(Fprocess_send_eof): Transfer proc_encode_coding_system
Richard M. Stallman <rms@gnu.org>
parents:
22864
diff
changeset
|
4289 XSETINT (XPROCESS (proc)->outfd, new_outfd); |
| 578 | 4290 } |
| 4291 #endif /* VMS */ | |
| 4292 return process; | |
| 4293 } | |
| 4294 | |
| 4295 /* Kill all processes associated with `buffer'. | |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4296 If `buffer' is nil, kill all processes */ |
| 578 | 4297 |
|
20382
dbad9367d232
(create_process, deactivate_process, close_process_descs):
Andreas Schwab <schwab@suse.de>
parents:
20225
diff
changeset
|
4298 void |
| 578 | 4299 kill_buffer_processes (buffer) |
| 4300 Lisp_Object buffer; | |
| 4301 { | |
| 4302 Lisp_Object tail, proc; | |
| 4303 | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
4304 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) |
| 578 | 4305 { |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
4306 proc = XCDR (XCAR (tail)); |
|
9952
9daedd94a204
(NETCONN_P, kill_buffer_processes): Use the new type-test macros.
Karl Heuer <kwzh@gnu.org>
parents:
9882
diff
changeset
|
4307 if (GC_PROCESSP (proc) |
| 578 | 4308 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) |
| 4309 { | |
| 4310 if (NETCONN_P (proc)) | |
|
7764
fad00b057e50
(kill_buffer_processes): For net conn, use Fdelete_process.
Richard M. Stallman <rms@gnu.org>
parents:
7748
diff
changeset
|
4311 Fdelete_process (proc); |
|
5134
0a4e46e15304
(wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
4998
diff
changeset
|
4312 else if (XINT (XPROCESS (proc)->infd) >= 0) |
| 578 | 4313 process_send_signal (proc, SIGHUP, Qnil, 1); |
| 4314 } | |
| 4315 } | |
| 4316 } | |
| 4317 | |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4318 /* On receipt of a signal that a child status has changed, loop asking |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4319 about children with changed statuses until the system says there |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4320 are no more. |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4321 |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4322 All we do is change the status; we do not run sentinels or print |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4323 notifications. That is saved for the next time keyboard input is |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4324 done, in order to avoid timing errors. |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4325 |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4326 ** WARNING: this can be called during garbage collection. |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4327 Therefore, it must not be fooled by the presence of mark bits in |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4328 Lisp objects. |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4329 |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4330 ** USG WARNING: Although it is not obvious from the documentation |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4331 in signal(2), on a USG system the SIGCLD handler MUST NOT call |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4332 signal() before executing at least one wait(), otherwise the |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4333 handler will be called again, resulting in an infinite loop. The |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4334 relevant portion of the documentation reads "SIGCLD signals will be |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4335 queued and the signal-catching function will be continually |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4336 reentered until the queue is empty". Invoking signal() causes the |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4337 kernel to reexamine the SIGCLD queue. Fred Fish, UniSoft Systems |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4338 Inc. */ |
| 578 | 4339 |
| 4340 SIGTYPE | |
| 4341 sigchld_handler (signo) | |
| 4342 int signo; | |
| 4343 { | |
| 4344 int old_errno = errno; | |
| 4345 Lisp_Object proc; | |
| 4346 register struct Lisp_Process *p; | |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4347 extern EMACS_TIME *input_available_clear_time; |
| 578 | 4348 |
| 4349 #ifdef BSD4_1 | |
| 4350 extern int sigheld; | |
| 4351 sigheld |= sigbit (SIGCHLD); | |
| 4352 #endif | |
| 4353 | |
| 4354 while (1) | |
| 4355 { | |
| 4356 register int pid; | |
| 4357 WAITTYPE w; | |
| 4358 Lisp_Object tail; | |
| 4359 | |
| 4360 #ifdef WNOHANG | |
| 4361 #ifndef WUNTRACED | |
| 4362 #define WUNTRACED 0 | |
| 4363 #endif /* no WUNTRACED */ | |
| 4364 /* Keep trying to get a status until we get a definitive result. */ | |
| 4365 do | |
| 4366 { | |
| 4367 errno = 0; | |
| 4368 pid = wait3 (&w, WNOHANG | WUNTRACED, 0); | |
| 4369 } | |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4370 while (pid < 0 && errno == EINTR); |
| 578 | 4371 |
| 4372 if (pid <= 0) | |
| 4373 { | |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4374 /* PID == 0 means no processes found, PID == -1 means a real |
|
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4375 failure. We have done all our job, so return. */ |
| 578 | 4376 |
| 4377 /* USG systems forget handlers when they are used; | |
| 4378 must reestablish each time */ | |
|
16116
80a67b8f39e9
(create_process_1, sigchld_handler) [POSIX_SIGNALS]:
Richard M. Stallman <rms@gnu.org>
parents:
16076
diff
changeset
|
4379 #if defined (USG) && !defined (POSIX_SIGNALS) |
| 578 | 4380 signal (signo, sigchld_handler); /* WARNING - must come after wait3() */ |
| 4381 #endif | |
| 4382 #ifdef BSD4_1 | |
| 4383 sigheld &= ~sigbit (SIGCHLD); | |
| 4384 sigrelse (SIGCHLD); | |
| 4385 #endif | |
| 4386 errno = old_errno; | |
| 4387 return; | |
| 4388 } | |
| 4389 #else | |
| 4390 pid = wait (&w); | |
| 4391 #endif /* no WNOHANG */ | |
| 4392 | |
| 4393 /* Find the process that signaled us, and record its status. */ | |
| 4394 | |
| 4395 p = 0; | |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4396 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) |
| 578 | 4397 { |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
4398 proc = XCDR (XCAR (tail)); |
| 578 | 4399 p = XPROCESS (proc); |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4400 if (GC_EQ (p->childp, Qt) && XINT (p->pid) == pid) |
| 578 | 4401 break; |
| 4402 p = 0; | |
| 4403 } | |
| 4404 | |
| 4405 /* Look for an asynchronous process whose pid hasn't been filled | |
| 4406 in yet. */ | |
| 4407 if (p == 0) | |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4408 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) |
| 578 | 4409 { |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
4410 proc = XCDR (XCAR (tail)); |
| 578 | 4411 p = XPROCESS (proc); |
|
39361
2d3bee6a3848
(sigchld_handler): Use GC_CONSP, GC_INTEGERP, GC_EQ
Gerd Moellmann <gerd@gnu.org>
parents:
37758
diff
changeset
|
4412 if (GC_INTEGERP (p->pid) && XINT (p->pid) == -1) |
| 578 | 4413 break; |
| 4414 p = 0; | |
| 4415 } | |
| 4416 | |
| 4417 /* Change the status of the process that was found. */ | |
| 4418 if (p != 0) | |
| 4419 { | |
| 4420 union { int i; WAITTYPE wt; } u; | |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4421 int clear_desc_flag = 0; |
| 578 | 4422 |
| 4423 XSETINT (p->tick, ++process_tick); | |
| 4424 u.wt = w; | |
|
12324
41bd44279127
(sigchld_handler): Change XSETFASTINT to XSETINT.
Richard M. Stallman <rms@gnu.org>
parents:
12215
diff
changeset
|
4425 XSETINT (p->raw_status_low, u.i & 0xffff); |
|
41bd44279127
(sigchld_handler): Change XSETFASTINT to XSETINT.
Richard M. Stallman <rms@gnu.org>
parents:
12215
diff
changeset
|
4426 XSETINT (p->raw_status_high, u.i >> 16); |
| 578 | 4427 |
| 4428 /* If process has terminated, stop waiting for its output. */ | |
|
9793
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4429 if ((WIFSIGNALED (w) || WIFEXITED (w)) |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4430 && XINT (p->infd) >= 0) |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4431 clear_desc_flag = 1; |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4432 |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4433 /* We use clear_desc_flag to avoid a compiler bug in Microsoft C. */ |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4434 if (clear_desc_flag) |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4435 { |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4436 FD_CLR (XINT (p->infd), &input_wait_mask); |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4437 FD_CLR (XINT (p->infd), &non_keyboard_wait_mask); |
|
28267fcc61be
Use macros IS_ANY_SEP, IS_DIRECTORY_SEP,
Richard M. Stallman <rms@gnu.org>
parents:
9705
diff
changeset
|
4438 } |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4439 |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4440 /* Tell wait_reading_process_input that it needs to wake up and |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4441 look around. */ |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4442 if (input_available_clear_time) |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4443 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
| 578 | 4444 } |
| 4445 | |
| 4446 /* There was no asynchronous process found for that id. Check | |
| 4447 if we have a synchronous process. */ | |
| 4448 else | |
| 4449 { | |
| 4450 synch_process_alive = 0; | |
| 4451 | |
| 4452 /* Report the status of the synchronous process. */ | |
| 4453 if (WIFEXITED (w)) | |
| 4454 synch_process_retcode = WRETCODE (w); | |
| 4455 else if (WIFSIGNALED (w)) | |
|
5579
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4456 { |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4457 int code = WTERMSIG (w); |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4458 char *signame; |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4459 |
|
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26313
diff
changeset
|
4460 synchronize_system_messages_locale (); |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4461 signame = strsignal (code); |
|
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
4462 |
|
5579
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4463 if (signame == 0) |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4464 signame = "unknown"; |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4465 |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4466 synch_process_death = signame; |
|
466bc8ef8e21
(sigchld_handler, status_message): Handle a NULL in sys_siglist.
Richard M. Stallman <rms@gnu.org>
parents:
5561
diff
changeset
|
4467 } |
|
1925
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4468 |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4469 /* Tell wait_reading_process_input that it needs to wake up and |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4470 look around. */ |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4471 if (input_available_clear_time) |
|
3ddb163a9201
* process.c: Make sure we don't miss processes exiting, by having
Jim Blandy <jimb@redhat.com>
parents:
1886
diff
changeset
|
4472 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); |
| 578 | 4473 } |
| 4474 | |
| 4475 /* On some systems, we must return right away. | |
| 4476 If any more processes want to signal us, we will | |
| 4477 get another signal. | |
| 4478 Otherwise (on systems that have WNOHANG), loop around | |
| 4479 to use up all the processes that have something to tell us. */ | |
|
39406
9dd4ad9bc53e
(sigchld_handler) [LINUX]: Don't return from
Gerd Moellmann <gerd@gnu.org>
parents:
39361
diff
changeset
|
4480 #if (defined WINDOWSNT \ |
|
41969
e669966d496e
Test GNU_LINUX, not LINUX.
Richard M. Stallman <rms@gnu.org>
parents:
41856
diff
changeset
|
4481 || (defined USG && !defined GNU_LINUX \ |
|
39406
9dd4ad9bc53e
(sigchld_handler) [LINUX]: Don't return from
Gerd Moellmann <gerd@gnu.org>
parents:
39361
diff
changeset
|
4482 && !(defined HPUX && defined WNOHANG))) |
|
16116
80a67b8f39e9
(create_process_1, sigchld_handler) [POSIX_SIGNALS]:
Richard M. Stallman <rms@gnu.org>
parents:
16076
diff
changeset
|
4483 #if defined (USG) && ! defined (POSIX_SIGNALS) |
| 578 | 4484 signal (signo, sigchld_handler); |
| 4485 #endif | |
| 4486 errno = old_errno; | |
| 4487 return; | |
| 4488 #endif /* USG, but not HPUX with WNOHANG */ | |
| 4489 } | |
| 4490 } | |
| 4491 | |
| 4492 | |
| 4493 static Lisp_Object | |
| 4494 exec_sentinel_unwind (data) | |
| 4495 Lisp_Object data; | |
| 4496 { | |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
4497 XPROCESS (XCAR (data))->sentinel = XCDR (data); |
| 578 | 4498 return Qnil; |
| 4499 } | |
| 4500 | |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4501 static Lisp_Object |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4502 exec_sentinel_error_handler (error) |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4503 Lisp_Object error; |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4504 { |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4505 cmd_error_internal (error, "error in process sentinel: "); |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4506 Vinhibit_quit = Qt; |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4507 update_echo_area (); |
|
11277
d4547e4b0aab
(read_process_output_error_handler)
Richard M. Stallman <rms@gnu.org>
parents:
11235
diff
changeset
|
4508 Fsleep_for (make_number (2), Qnil); |
| 27558 | 4509 return Qt; |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4510 } |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4511 |
| 578 | 4512 static void |
| 4513 exec_sentinel (proc, reason) | |
| 4514 Lisp_Object proc, reason; | |
| 4515 { | |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4516 Lisp_Object sentinel, obuffer, odeactivate, okeymap; |
| 578 | 4517 register struct Lisp_Process *p = XPROCESS (proc); |
| 4518 int count = specpdl_ptr - specpdl; | |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4519 int outer_running_asynch_code = running_asynch_code; |
|
23460
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
4520 int waiting = waiting_for_user_input_p; |
| 578 | 4521 |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4522 /* No need to gcpro these, because all we do with them later |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4523 is test them for EQness, and none of them should be a string. */ |
|
7454
8d9e41a175fa
(exec_sentinel): Don't deactivate the mark. Check for asynch buffer switch.
Karl Heuer <kwzh@gnu.org>
parents:
7414
diff
changeset
|
4524 odeactivate = Vdeactivate_mark; |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4525 XSETBUFFER (obuffer, current_buffer); |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4526 okeymap = current_buffer->keymap; |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4527 |
| 578 | 4528 sentinel = p->sentinel; |
| 4529 if (NILP (sentinel)) | |
| 4530 return; | |
| 4531 | |
| 4532 /* Zilch the sentinel while it's running, to avoid recursive invocations; | |
| 4533 assure that it gets restored no matter how the sentinel exits. */ | |
| 4534 p->sentinel = Qnil; | |
| 4535 record_unwind_protect (exec_sentinel_unwind, Fcons (proc, sentinel)); | |
| 4536 /* Inhibit quit so that random quits don't screw up a running filter. */ | |
| 4537 specbind (Qinhibit_quit, Qt); | |
|
8231
5226ed89c1a6
(Qlast_nonmenu_event): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8063
diff
changeset
|
4538 specbind (Qlast_nonmenu_event, Qt); |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4539 |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4540 /* In case we get recursively called, |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4541 and we already saved the match data nonrecursively, |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4542 save the same match data in safely recursive fashion. */ |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4543 if (outer_running_asynch_code) |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4544 { |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4545 Lisp_Object tem; |
|
16728
309a750fd5c0
(read_process_output, exec_sentinel):
Richard M. Stallman <rms@gnu.org>
parents:
16718
diff
changeset
|
4546 tem = Fmatch_data (Qnil, Qnil); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4547 restore_match_data (); |
|
21177
73f8ae8312c8
(exec_sentinel, read_process_output): Fstore_match_data => Fset_match_data.
Richard M. Stallman <rms@gnu.org>
parents:
21049
diff
changeset
|
4548 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); |
|
73f8ae8312c8
(exec_sentinel, read_process_output): Fstore_match_data => Fset_match_data.
Richard M. Stallman <rms@gnu.org>
parents:
21049
diff
changeset
|
4549 Fset_match_data (tem); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4550 } |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4551 |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4552 /* For speed, if a search happens within this code, |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4553 save the match data in a special nonrecursive fashion. */ |
|
10032
f689803caa92
Added code for automatically saving and restoring the match data
Francesco Potort? <pot@gnu.org>
parents:
9969
diff
changeset
|
4554 running_asynch_code = 1; |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4555 |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4556 internal_condition_case_1 (read_process_output_call, |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4557 Fcons (sentinel, |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4558 Fcons (proc, Fcons (reason, Qnil))), |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4559 !NILP (Vdebug_on_error) ? Qnil : Qerror, |
|
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4560 exec_sentinel_error_handler); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4561 |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4562 /* If we saved the match data nonrecursively, restore it now. */ |
|
10032
f689803caa92
Added code for automatically saving and restoring the match data
Francesco Potort? <pot@gnu.org>
parents:
9969
diff
changeset
|
4563 restore_match_data (); |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4564 running_asynch_code = outer_running_asynch_code; |
|
7454
8d9e41a175fa
(exec_sentinel): Don't deactivate the mark. Check for asynch buffer switch.
Karl Heuer <kwzh@gnu.org>
parents:
7414
diff
changeset
|
4565 |
|
8d9e41a175fa
(exec_sentinel): Don't deactivate the mark. Check for asynch buffer switch.
Karl Heuer <kwzh@gnu.org>
parents:
7414
diff
changeset
|
4566 Vdeactivate_mark = odeactivate; |
|
23460
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
4567 |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
4568 /* Restore waiting_for_user_input_p as it was |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
4569 when we were called, in case the filter clobbered it. */ |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
4570 waiting_for_user_input_p = waiting; |
|
94f4ba741f22
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
23405
diff
changeset
|
4571 |
|
12808
4db1f387e85f
(read_process_output, exec_sentinel): Call
Richard M. Stallman <rms@gnu.org>
parents:
12749
diff
changeset
|
4572 #if 0 |
|
10914
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4573 if (! EQ (Fcurrent_buffer (), obuffer) |
|
413d44c0bd41
(exec_sentinel, read_process_output): If running filter
Richard M. Stallman <rms@gnu.org>
parents:
10744
diff
changeset
|
4574 || ! EQ (current_buffer->keymap, okeymap)) |
|
12808
4db1f387e85f
(read_process_output, exec_sentinel): Call
Richard M. Stallman <rms@gnu.org>
parents:
12749
diff
changeset
|
4575 #endif |
|
13159
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
4576 /* But do it only if the caller is actually going to read events. |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
4577 Otherwise there's no need to make him wake up, and it could |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
4578 cause trouble (for example it would make Fsit_for return). */ |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
4579 if (waiting_for_user_input_p == -1) |
|
2af96ac471bc
(exec_sentinel, read_process_output):
Richard M. Stallman <rms@gnu.org>
parents:
12808
diff
changeset
|
4580 record_asynch_buffer_change (); |
|
7454
8d9e41a175fa
(exec_sentinel): Don't deactivate the mark. Check for asynch buffer switch.
Karl Heuer <kwzh@gnu.org>
parents:
7414
diff
changeset
|
4581 |
|
5561
fd7524d61a8d
(read_process_output): Supply second arg to unbind_to.
Richard M. Stallman <rms@gnu.org>
parents:
5548
diff
changeset
|
4582 unbind_to (count, Qnil); |
| 578 | 4583 } |
| 4584 | |
| 4585 /* Report all recent events of a change in process status | |
| 4586 (either run the sentinel or output a message). | |
| 4587 This is done while Emacs is waiting for keyboard input. */ | |
| 4588 | |
|
20382
dbad9367d232
(create_process, deactivate_process, close_process_descs):
Andreas Schwab <schwab@suse.de>
parents:
20225
diff
changeset
|
4589 void |
| 578 | 4590 status_notify () |
| 4591 { | |
| 4592 register Lisp_Object proc, buffer; | |
|
6515
df7438605e1e
(status_notify): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6429
diff
changeset
|
4593 Lisp_Object tail, msg; |
| 578 | 4594 struct gcpro gcpro1, gcpro2; |
| 4595 | |
|
6515
df7438605e1e
(status_notify): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6429
diff
changeset
|
4596 tail = Qnil; |
|
df7438605e1e
(status_notify): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6429
diff
changeset
|
4597 msg = Qnil; |
| 578 | 4598 /* We need to gcpro tail; if read_process_output calls a filter |
| 4599 which deletes a process and removes the cons to which tail points | |
| 4600 from Vprocess_alist, and then causes a GC, tail is an unprotected | |
| 4601 reference. */ | |
| 4602 GCPRO2 (tail, msg); | |
| 4603 | |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4604 /* Set this now, so that if new processes are created by sentinels |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4605 that we run, we get called again to handle their status changes. */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4606 update_tick = process_tick; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4607 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4608 for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail)) |
| 578 | 4609 { |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4610 Lisp_Object symbol; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4611 register struct Lisp_Process *p; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4612 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4613 proc = Fcdr (Fcar (tail)); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4614 p = XPROCESS (proc); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4615 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4616 if (XINT (p->tick) != XINT (p->update_tick)) |
| 578 | 4617 { |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4618 XSETINT (p->update_tick, XINT (p->tick)); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4619 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4620 /* If process is still active, read any output that remains. */ |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4621 while (! EQ (p->filter, Qt) |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
4622 && ! EQ (p->status, Qconnect) |
|
16644
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4623 && XINT (p->infd) >= 0 |
|
3a93437adce1
(status_notify): Test p->infd > 0
Richard M. Stallman <rms@gnu.org>
parents:
16464
diff
changeset
|
4624 && read_process_output (proc, XINT (p->infd)) > 0); |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4625 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4626 buffer = p->buffer; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4627 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4628 /* Get the text to use for the message. */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4629 if (!NILP (p->raw_status_low)) |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4630 update_status (p); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4631 msg = status_message (p->status); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4632 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4633 /* If process is terminated, deactivate it or delete it. */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4634 symbol = p->status; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4635 if (CONSP (p->status)) |
|
25645
a14111a2a100
Use XCAR, XCDR, XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25356
diff
changeset
|
4636 symbol = XCAR (p->status); |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4637 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4638 if (EQ (symbol, Qsignal) || EQ (symbol, Qexit) |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4639 || EQ (symbol, Qclosed)) |
| 578 | 4640 { |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4641 if (delete_exited_processes) |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4642 remove_process (proc); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4643 else |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4644 deactivate_process (proc); |
| 578 | 4645 } |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4646 |
|
16464
c1f19d8e5b80
(status_notify): Update p->tick again
Richard M. Stallman <rms@gnu.org>
parents:
16220
diff
changeset
|
4647 /* The actions above may have further incremented p->tick. |
|
c1f19d8e5b80
(status_notify): Update p->tick again
Richard M. Stallman <rms@gnu.org>
parents:
16220
diff
changeset
|
4648 So set p->update_tick again |
|
c1f19d8e5b80
(status_notify): Update p->tick again
Richard M. Stallman <rms@gnu.org>
parents:
16220
diff
changeset
|
4649 so that an error in the sentinel will not cause |
|
c1f19d8e5b80
(status_notify): Update p->tick again
Richard M. Stallman <rms@gnu.org>
parents:
16220
diff
changeset
|
4650 this code to be run again. */ |
|
c1f19d8e5b80
(status_notify): Update p->tick again
Richard M. Stallman <rms@gnu.org>
parents:
16220
diff
changeset
|
4651 XSETINT (p->update_tick, XINT (p->tick)); |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4652 /* Now output the message suitably. */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4653 if (!NILP (p->sentinel)) |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4654 exec_sentinel (proc, msg); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4655 /* Don't bother with a message in the buffer |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4656 when a process becomes runnable. */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4657 else if (!EQ (symbol, Qrun) && !NILP (buffer)) |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4658 { |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4659 Lisp_Object ro, tem; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4660 struct buffer *old = current_buffer; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4661 int opoint, opoint_byte; |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4662 int before, before_byte; |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4663 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4664 ro = XBUFFER (buffer)->read_only; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4665 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4666 /* Avoid error if buffer is deleted |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4667 (probably that's why the process is dead, too) */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4668 if (NILP (XBUFFER (buffer)->name)) |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4669 continue; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4670 Fset_buffer (buffer); |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
4671 |
|
16039
855c8d8ba0f0
Change all references from point to PT.
Karl Heuer <kwzh@gnu.org>
parents:
15895
diff
changeset
|
4672 opoint = PT; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4673 opoint_byte = PT_BYTE; |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4674 /* Insert new output into buffer |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4675 at the current end-of-output marker, |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4676 thus preserving logical ordering of input and output. */ |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4677 if (XMARKER (p->mark)->buffer) |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4678 Fgoto_char (p->mark); |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4679 else |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4680 SET_PT_BOTH (ZV, ZV_BYTE); |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
4681 |
|
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
4682 before = PT; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4683 before_byte = PT_BYTE; |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4684 |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4685 tem = current_buffer->read_only; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4686 current_buffer->read_only = Qnil; |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4687 insert_string ("\nProcess "); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4688 Finsert (1, &p->name); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4689 insert_string (" "); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4690 Finsert (1, &msg); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4691 current_buffer->read_only = tem; |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4692 set_marker_both (p->mark, p->buffer, PT, PT_BYTE); |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4693 |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
4694 if (opoint >= before) |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4695 SET_PT_BOTH (opoint + (PT - before), |
|
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4696 opoint_byte + (PT_BYTE - before_byte)); |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
4697 else |
|
20551
5f17380c85f1
(status_notify): Use byte and char pointers.
Richard M. Stallman <rms@gnu.org>
parents:
20433
diff
changeset
|
4698 SET_PT_BOTH (opoint, opoint_byte); |
|
17604
77b137e2d9a7
(read_process_output): Update opoint, old_begv and old_zv
Richard M. Stallman <rms@gnu.org>
parents:
17247
diff
changeset
|
4699 |
|
12215
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4700 set_buffer_internal (old); |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4701 } |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4702 } |
|
2f1f03964f08
(status_notify): Undo May 18 change.
Richard M. Stallman <rms@gnu.org>
parents:
12132
diff
changeset
|
4703 } /* end for */ |
| 578 | 4704 |
| 4705 update_mode_lines++; /* in case buffers use %s in mode-line-format */ | |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
4706 redisplay_preserve_echo_area (13); |
| 578 | 4707 |
| 4708 UNGCPRO; | |
| 4709 } | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4710 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4711 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4712 DEFUN ("set-process-coding-system", Fset_process_coding_system, |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4713 Sset_process_coding_system, 1, 3, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4714 doc: /* Set coding systems of PROCESS to DECODING and ENCODING. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4715 DECODING will be used to decode subprocess output and ENCODING to |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4716 encode subprocess input. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4717 (proc, decoding, encoding) |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4718 register Lisp_Object proc, decoding, encoding; |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4719 { |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4720 register struct Lisp_Process *p; |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4721 |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
4722 CHECK_PROCESS (proc); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4723 p = XPROCESS (proc); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4724 if (XINT (p->infd) < 0) |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4725 error ("Input file descriptor of %s closed", XSTRING (p->name)->data); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4726 if (XINT (p->outfd) < 0) |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4727 error ("Output file descriptor of %s closed", XSTRING (p->name)->data); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4728 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4729 p->decode_coding_system = Fcheck_coding_system (decoding); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4730 p->encode_coding_system = Fcheck_coding_system (encoding); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4731 setup_coding_system (decoding, |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
4732 proc_decode_coding_system[XINT (p->infd)]); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4733 setup_coding_system (encoding, |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
4734 proc_encode_coding_system[XINT (p->outfd)]); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4735 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4736 return Qnil; |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4737 } |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4738 |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4739 DEFUN ("process-coding-system", |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4740 Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4741 doc: /* Return a cons of coding systems for decoding and encoding of PROCESS. */) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4742 (proc) |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4743 register Lisp_Object proc; |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4744 { |
|
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Jan?k <Pavel@Janik.cz>
parents:
40641
diff
changeset
|
4745 CHECK_PROCESS (proc); |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4746 return Fcons (XPROCESS (proc)->decode_coding_system, |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4747 XPROCESS (proc)->encode_coding_system); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4748 } |
| 578 | 4749 |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4750 /* The first time this is called, assume keyboard input comes from DESC |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4751 instead of from where we used to expect it. |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4752 Subsequent calls mean assume input keyboard can come from DESC |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4753 in addition to other places. */ |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4754 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4755 static int add_keyboard_wait_descriptor_called_flag; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4756 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4757 void |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4758 add_keyboard_wait_descriptor (desc) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4759 int desc; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4760 { |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4761 if (! add_keyboard_wait_descriptor_called_flag) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4762 FD_CLR (0, &input_wait_mask); |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4763 add_keyboard_wait_descriptor_called_flag = 1; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4764 FD_SET (desc, &input_wait_mask); |
|
17224
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
4765 FD_SET (desc, &non_process_wait_mask); |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4766 if (desc > max_keyboard_desc) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4767 max_keyboard_desc = desc; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4768 } |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4769 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4770 /* From now on, do not expect DESC to give keyboard input. */ |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4771 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4772 void |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4773 delete_keyboard_wait_descriptor (desc) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4774 int desc; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4775 { |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4776 int fd; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4777 int lim = max_keyboard_desc; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4778 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4779 FD_CLR (desc, &input_wait_mask); |
|
17224
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
4780 FD_CLR (desc, &non_process_wait_mask); |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4781 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4782 if (desc == max_keyboard_desc) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4783 for (fd = 0; fd < lim; fd++) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4784 if (FD_ISSET (fd, &input_wait_mask) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4785 && !FD_ISSET (fd, &non_keyboard_wait_mask)) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4786 max_keyboard_desc = fd; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4787 } |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4788 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4789 /* Return nonzero if *MASK has a bit set |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4790 that corresponds to one of the keyboard input descriptors. */ |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4791 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4792 int |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4793 keyboard_bit_set (mask) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4794 SELECT_TYPE *mask; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4795 { |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4796 int fd; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4797 |
|
12541
33a4586124e9
(keyboard_bit_set): Fix one-off in loop end.
Karl Heuer <kwzh@gnu.org>
parents:
12491
diff
changeset
|
4798 for (fd = 0; fd <= max_keyboard_desc; fd++) |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4799 if (FD_ISSET (fd, mask) && FD_ISSET (fd, &input_wait_mask) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4800 && !FD_ISSET (fd, &non_keyboard_wait_mask)) |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4801 return 1; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4802 |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4803 return 0; |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4804 } |
|
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4805 |
| 21514 | 4806 void |
| 578 | 4807 init_process () |
| 4808 { | |
| 4809 register int i; | |
| 4810 | |
| 4811 #ifdef SIGCHLD | |
| 4812 #ifndef CANNOT_DUMP | |
| 4813 if (! noninteractive || initialized) | |
| 4814 #endif | |
| 4815 signal (SIGCHLD, sigchld_handler); | |
| 4816 #endif | |
| 4817 | |
| 4818 FD_ZERO (&input_wait_mask); | |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4819 FD_ZERO (&non_keyboard_wait_mask); |
|
17224
dd2545e79add
(wait_reading_process_input): If wait_for_cell,
Richard M. Stallman <rms@gnu.org>
parents:
17110
diff
changeset
|
4820 FD_ZERO (&non_process_wait_mask); |
|
7044
7032d07f5ad9
(max_process_desc): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
7013
diff
changeset
|
4821 max_process_desc = 0; |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
4822 |
|
9686
cd788aa8cb2a
Handle multiple keyboard input descriptors.
Richard M. Stallman <rms@gnu.org>
parents:
9334
diff
changeset
|
4823 FD_SET (0, &input_wait_mask); |
|
4682
c4d471244116
(keyboard_descriptor): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
4639
diff
changeset
|
4824 |
| 578 | 4825 Vprocess_alist = Qnil; |
| 4826 for (i = 0; i < MAXDESC; i++) | |
| 4827 { | |
| 4828 chan_process[i] = Qnil; | |
| 4829 proc_buffered_char[i] = -1; | |
| 4830 } | |
|
17110
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
4831 bzero (proc_decode_coding_system, sizeof proc_decode_coding_system); |
|
3a348cbb354f
(Fstart_process, Fopen_network_stream): Do not perform
Kenichi Handa <handa@m17n.org>
parents:
17041
diff
changeset
|
4832 bzero (proc_encode_coding_system, sizeof proc_encode_coding_system); |
| 578 | 4833 } |
|
4231
91a883c56382
(Fget_buffer_process): Delete doc string from
Richard M. Stallman <rms@gnu.org>
parents:
4057
diff
changeset
|
4834 |
| 21514 | 4835 void |
| 578 | 4836 syms_of_process () |
| 4837 { | |
| 4838 Qprocessp = intern ("processp"); | |
| 4839 staticpro (&Qprocessp); | |
| 4840 Qrun = intern ("run"); | |
| 4841 staticpro (&Qrun); | |
| 4842 Qstop = intern ("stop"); | |
| 4843 staticpro (&Qstop); | |
| 4844 Qsignal = intern ("signal"); | |
| 4845 staticpro (&Qsignal); | |
| 4846 | |
| 4847 /* Qexit is already staticpro'd by syms_of_eval; don't staticpro it | |
| 4848 here again. | |
| 4849 | |
| 4850 Qexit = intern ("exit"); | |
| 4851 staticpro (&Qexit); */ | |
| 4852 | |
| 4853 Qopen = intern ("open"); | |
| 4854 staticpro (&Qopen); | |
| 4855 Qclosed = intern ("closed"); | |
| 4856 staticpro (&Qclosed); | |
|
43598
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
4857 Qconnect = intern ("connect"); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
4858 staticpro (&Qconnect); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
4859 Qfailed = intern ("failed"); |
|
f49377cf2e3c
(Qconnect, Qfailed): New variables.
Kim F. Storm <storm@cua.dk>
parents:
42600
diff
changeset
|
4860 staticpro (&Qfailed); |
| 578 | 4861 |
|
8231
5226ed89c1a6
(Qlast_nonmenu_event): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8063
diff
changeset
|
4862 Qlast_nonmenu_event = intern ("last-nonmenu-event"); |
|
5226ed89c1a6
(Qlast_nonmenu_event): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8063
diff
changeset
|
4863 staticpro (&Qlast_nonmenu_event); |
|
5226ed89c1a6
(Qlast_nonmenu_event): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8063
diff
changeset
|
4864 |
| 578 | 4865 staticpro (&Vprocess_alist); |
| 4866 | |
| 4867 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4868 doc: /* *Non-nil means delete processes immediately when they exit. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4869 nil means don't delete them until `list-processes' is run. */); |
| 578 | 4870 |
| 4871 delete_exited_processes = 1; | |
| 4872 | |
| 4873 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type, | |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4874 doc: /* Control type of device used to communicate with subprocesses. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4875 Values are nil to use a pipe, or t or `pty' to use a pty. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4876 The value has no effect if the system has no ptys or if all ptys are busy: |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4877 then a pipe is used in any case. |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
4878 The value takes effect when `start-process' is called. */); |
| 578 | 4879 Vprocess_connection_type = Qt; |
| 4880 | |
| 4881 defsubr (&Sprocessp); | |
| 4882 defsubr (&Sget_process); | |
| 4883 defsubr (&Sget_buffer_process); | |
| 4884 defsubr (&Sdelete_process); | |
| 4885 defsubr (&Sprocess_status); | |
| 4886 defsubr (&Sprocess_exit_status); | |
| 4887 defsubr (&Sprocess_id); | |
| 4888 defsubr (&Sprocess_name); | |
|
9030
b14532c71632
(exec_sentinel_error_handler): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8570
diff
changeset
|
4889 defsubr (&Sprocess_tty_name); |
| 578 | 4890 defsubr (&Sprocess_command); |
| 4891 defsubr (&Sset_process_buffer); | |
| 4892 defsubr (&Sprocess_buffer); | |
| 4893 defsubr (&Sprocess_mark); | |
| 4894 defsubr (&Sset_process_filter); | |
| 4895 defsubr (&Sprocess_filter); | |
| 4896 defsubr (&Sset_process_sentinel); | |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
4897 defsubr (&Sprocess_sentinel); |
|
6830
bcaddbe53068
(Fset_process_window_size): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6823
diff
changeset
|
4898 defsubr (&Sset_process_window_size); |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
4899 defsubr (&Sset_process_inherit_coding_system_flag); |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
4900 defsubr (&Sprocess_inherit_coding_system_flag); |
| 578 | 4901 defsubr (&Sprocess_kill_without_query); |
|
16058
924aeb9ed7c3
(Fprocess_contact): New function.
Richard M. Stallman <rms@gnu.org>
parents:
16053
diff
changeset
|
4902 defsubr (&Sprocess_contact); |
| 578 | 4903 defsubr (&Slist_processes); |
| 4904 defsubr (&Sprocess_list); | |
| 4905 defsubr (&Sstart_process); | |
| 4906 #ifdef HAVE_SOCKETS | |
| 4907 defsubr (&Sopen_network_stream); | |
| 4908 #endif /* HAVE_SOCKETS */ | |
| 4909 defsubr (&Saccept_process_output); | |
| 4910 defsubr (&Sprocess_send_region); | |
| 4911 defsubr (&Sprocess_send_string); | |
| 4912 defsubr (&Sinterrupt_process); | |
| 4913 defsubr (&Skill_process); | |
| 4914 defsubr (&Squit_process); | |
| 4915 defsubr (&Sstop_process); | |
| 4916 defsubr (&Scontinue_process); | |
|
24352
023601636a18
(syms_of_process): defsubr it.
Richard M. Stallman <rms@gnu.org>
parents:
23930
diff
changeset
|
4917 defsubr (&Sprocess_running_child_p); |
| 578 | 4918 defsubr (&Sprocess_send_eof); |
| 4919 defsubr (&Ssignal_process); | |
| 4920 defsubr (&Swaiting_for_user_input_p); | |
| 4921 /* defsubr (&Sprocess_connection); */ | |
|
17041
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4922 defsubr (&Sset_process_coding_system); |
|
b61cbe595be5
Include charset.h and coding.h.
Karl Heuer <kwzh@gnu.org>
parents:
16780
diff
changeset
|
4923 defsubr (&Sprocess_coding_system); |
| 578 | 4924 } |
| 4925 | |
| 588 | 4926 |
| 4927 #else /* not subprocesses */ | |
| 4928 | |
| 4929 #include <sys/types.h> | |
| 4930 #include <errno.h> | |
| 4931 | |
| 4932 #include "lisp.h" | |
| 4933 #include "systime.h" | |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
4934 #include "charset.h" |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
4935 #include "coding.h" |
| 588 | 4936 #include "termopts.h" |
|
12132
017f32786ed3
[!subprocesses]: Include sysselect.h.
Karl Heuer <kwzh@gnu.org>
parents:
11926
diff
changeset
|
4937 #include "sysselect.h" |
| 588 | 4938 |
| 765 | 4939 extern int frame_garbaged; |
| 588 | 4940 |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
4941 extern EMACS_TIME timer_check (); |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
4942 extern int timers_run; |
| 588 | 4943 |
| 4944 /* As described above, except assuming that there are no subprocesses: | |
| 4945 | |
| 4946 Wait for timeout to elapse and/or keyboard input to be available. | |
| 4947 | |
| 4948 time_limit is: | |
| 4949 timeout in seconds, or | |
| 4950 zero for no limit, or | |
| 4951 -1 means gobble data immediately available but don't wait for any. | |
| 4952 | |
| 650 | 4953 read_kbd is a Lisp_Object: |
| 588 | 4954 0 to ignore keyboard input, or |
| 4955 1 to return when input is available, or | |
| 4956 -1 means caller will actually read the input, so don't throw to | |
| 4957 the quit handler. | |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4958 a cons cell, meaning wait until its car is non-nil |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4959 (and gobble terminal input into the buffer if any arrives), or |
| 588 | 4960 We know that read_kbd will never be a Lisp_Process, since |
| 4961 `subprocesses' isn't defined. | |
| 4962 | |
| 4963 do_display != 0 means redisplay should be done to show subprocess | |
|
6429
1dbe24a029fd
(wait_reading_process_input, both versions): Don't call
Richard M. Stallman <rms@gnu.org>
parents:
6393
diff
changeset
|
4964 output that arrives. |
| 588 | 4965 |
|
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3510
diff
changeset
|
4966 Return true iff we received input from any process. */ |
| 588 | 4967 |
| 4968 int | |
| 4969 wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) | |
| 650 | 4970 int time_limit, microsecs; |
| 4971 Lisp_Object read_kbd; | |
| 4972 int do_display; | |
| 588 | 4973 { |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
4974 register int nfds; |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
4975 EMACS_TIME end_time, timeout; |
|
14278
3562c5f43780
(wait_reading_process_input) [not subprocesses]: Do
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
4976 SELECT_TYPE waitchannels; |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
4977 int xerrno; |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
4978 /* Either nil or a cons cell, the car of which is of interest and |
|
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
4979 may be changed outside of this routine. */ |
|
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
4980 Lisp_Object wait_for_cell = Qnil; |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4981 |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4982 /* If waiting for non-nil in a cell, record where. */ |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4983 if (CONSP (read_kbd)) |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4984 { |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
4985 wait_for_cell = read_kbd; |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4986 XSETFASTINT (read_kbd, 0); |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
4987 } |
| 588 | 4988 |
| 4989 /* What does time_limit really mean? */ | |
| 4990 if (time_limit || microsecs) | |
| 4991 { | |
| 4992 EMACS_GET_TIME (end_time); | |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
4993 EMACS_SET_SECS_USECS (timeout, time_limit, microsecs); |
| 588 | 4994 EMACS_ADD_TIME (end_time, end_time, timeout); |
| 4995 } | |
| 4996 | |
| 4997 /* Turn off periodic alarms (in case they are in use) | |
| 4998 because the select emulator uses alarms. */ | |
|
27430
1aa71680fe50
(toplevel): Include atimer.h.
Gerd Moellmann <gerd@gnu.org>
parents:
27028
diff
changeset
|
4999 turn_on_atimers (0); |
| 588 | 5000 |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5001 while (1) |
| 588 | 5002 { |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5003 int timeout_reduced_for_timers = 0; |
| 588 | 5004 |
| 5005 /* If calling from keyboard input, do not quit | |
| 5006 since we want to return C-g as an input character. | |
| 5007 Otherwise, do pending quit if requested. */ | |
| 650 | 5008 if (XINT (read_kbd) >= 0) |
| 588 | 5009 QUIT; |
| 5010 | |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5011 /* Exit now if the cell we're waiting for became non-nil. */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
5012 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5013 break; |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5014 |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5015 /* Compute time from now till when time limit is up */ |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5016 /* Exit if already run out */ |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5017 if (time_limit == -1) |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5018 { |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5019 /* -1 specified for timeout means |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5020 gobble output available now |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5021 but don't wait at all. */ |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5022 |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5023 EMACS_SET_SECS_USECS (timeout, 0, 0); |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5024 } |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5025 else if (time_limit || microsecs) |
| 588 | 5026 { |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5027 EMACS_GET_TIME (timeout); |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5028 EMACS_SUB_TIME (timeout, end_time, timeout); |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5029 if (EMACS_TIME_NEG_P (timeout)) |
| 588 | 5030 break; |
| 5031 } | |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5032 else |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5033 { |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5034 EMACS_SET_SECS_USECS (timeout, 100000, 0); |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5035 } |
| 588 | 5036 |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5037 /* If our caller will not immediately handle keyboard events, |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5038 run timer events directly. |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5039 (Callers that will immediately read keyboard events |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5040 call timer_delay on their own.) */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
5041 if (NILP (wait_for_cell)) |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5042 { |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5043 EMACS_TIME timer_delay; |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5044 |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5045 do |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5046 { |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5047 int old_timers_run = timers_run; |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5048 timer_delay = timer_check (1); |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5049 if (timers_run != old_timers_run && do_display) |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5050 /* We must retry, since a timer may have requeued itself |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5051 and that could alter the time delay. */ |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
5052 redisplay_preserve_echo_area (14); |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5053 else |
|
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5054 break; |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5055 } |
|
34660
75866a7ebaec
(wait_reading_process_input): Check for pending
Gerd Moellmann <gerd@gnu.org>
parents:
34647
diff
changeset
|
5056 while (!detect_input_pending ()); |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5057 |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5058 /* If there is unread keyboard input, also return. */ |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5059 if (XINT (read_kbd) != 0 |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5060 && requeued_events_pending_p ()) |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5061 break; |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5062 |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5063 if (! EMACS_TIME_NEG_P (timer_delay) && time_limit != -1) |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5064 { |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5065 EMACS_TIME difference; |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5066 EMACS_SUB_TIME (difference, timer_delay, timeout); |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5067 if (EMACS_TIME_NEG_P (difference)) |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5068 { |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5069 timeout = timer_delay; |
|
14802
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5070 timeout_reduced_for_timers = 1; |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5071 } |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5072 } |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5073 } |
|
45827a5afe4d
[!subprocesses] (wait_reading_process_input):
Richard M. Stallman <rms@gnu.org>
parents:
14785
diff
changeset
|
5074 |
| 588 | 5075 /* Cause C-g and alarm signals to take immediate action, |
| 5076 and cause input available signals to zero out timeout. */ | |
| 650 | 5077 if (XINT (read_kbd) < 0) |
| 588 | 5078 set_waiting_for_input (&timeout); |
| 5079 | |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5080 /* Wait till there is something to do. */ |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5081 |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
5082 if (! XINT (read_kbd) && NILP (wait_for_cell)) |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5083 FD_ZERO (&waitchannels); |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5084 else |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5085 FD_SET (0, &waitchannels); |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5086 |
| 765 | 5087 /* If a frame has been newly mapped and needs updating, |
| 588 | 5088 reprocess its display stuff. */ |
|
6429
1dbe24a029fd
(wait_reading_process_input, both versions): Don't call
Richard M. Stallman <rms@gnu.org>
parents:
6393
diff
changeset
|
5089 if (frame_garbaged && do_display) |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5090 { |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5091 clear_waiting_for_input (); |
|
35336
002c02db42d3
Call redisplay_preserve_echo_area with additional arg.
Gerd Moellmann <gerd@gnu.org>
parents:
34660
diff
changeset
|
5092 redisplay_preserve_echo_area (15); |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5093 if (XINT (read_kbd) < 0) |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5094 set_waiting_for_input (&timeout); |
|
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5095 } |
| 588 | 5096 |
|
15025
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5097 if (XINT (read_kbd) && detect_input_pending ()) |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5098 { |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5099 nfds = 0; |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5100 FD_ZERO (&waitchannels); |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5101 } |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5102 else |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5103 nfds = select (1, &waitchannels, (SELECT_TYPE *)0, (SELECT_TYPE *)0, |
|
e5f54fd1c352
(wait_reading_process_input) [!subprocesses]:
Richard M. Stallman <rms@gnu.org>
parents:
15021
diff
changeset
|
5104 &timeout); |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5105 |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5106 xerrno = errno; |
| 588 | 5107 |
| 5108 /* Make C-g and alarm signals set flags again */ | |
| 5109 clear_waiting_for_input (); | |
| 5110 | |
| 5111 /* If we woke up due to SIGWINCH, actually change size now. */ | |
|
25356
5db69f7aadca
Call change_frame_size and do_pending_window_change with
Gerd Moellmann <gerd@gnu.org>
parents:
25262
diff
changeset
|
5112 do_pending_window_change (0); |
| 588 | 5113 |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5114 if (time_limit && nfds == 0 && ! timeout_reduced_for_timers) |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5115 /* We waited the full specified time, so return now. */ |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5116 break; |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5117 |
| 588 | 5118 if (nfds == -1) |
| 5119 { | |
| 5120 /* If the system call was interrupted, then go around the | |
| 5121 loop again. */ | |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5122 if (xerrno == EINTR) |
|
14278
3562c5f43780
(wait_reading_process_input) [not subprocesses]: Do
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
5123 FD_ZERO (&waitchannels); |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5124 else |
|
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
26019
diff
changeset
|
5125 error ("select error: %s", emacs_strerror (xerrno)); |
| 588 | 5126 } |
| 5127 #ifdef sun | |
| 5128 else if (nfds > 0 && (waitchannels & 1) && interrupt_input) | |
| 5129 /* System sometimes fails to deliver SIGIO. */ | |
| 5130 kill (getpid (), SIGIO); | |
| 5131 #endif | |
|
3915
55ed7a65746e
(wait_reading_process_input): Use SIGIO only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
3826
diff
changeset
|
5132 #ifdef SIGIO |
| 650 | 5133 if (XINT (read_kbd) && interrupt_input && (waitchannels & 1)) |
|
14736
b17ec81a6294
(wait_reading_process_input): Use getpid when generating SIGIO.
Richard M. Stallman <rms@gnu.org>
parents:
14671
diff
changeset
|
5134 kill (getpid (), SIGIO); |
|
3915
55ed7a65746e
(wait_reading_process_input): Use SIGIO only if defined.
Richard M. Stallman <rms@gnu.org>
parents:
3826
diff
changeset
|
5135 #endif |
| 588 | 5136 |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5137 /* Check for keyboard input */ |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5138 |
|
37413
49147b9fe206
(wait_reading_process_input) [!subprocesses]: Don't
Eli Zaretskii <eliz@gnu.org>
parents:
37398
diff
changeset
|
5139 if ((XINT (read_kbd) != 0) |
|
49147b9fe206
(wait_reading_process_input) [!subprocesses]: Don't
Eli Zaretskii <eliz@gnu.org>
parents:
37398
diff
changeset
|
5140 && detect_input_pending_run_timers (do_display)) |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5141 { |
|
37413
49147b9fe206
(wait_reading_process_input) [!subprocesses]: Don't
Eli Zaretskii <eliz@gnu.org>
parents:
37398
diff
changeset
|
5142 swallow_events (do_display); |
|
14806
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5143 if (detect_input_pending_run_timers (do_display)) |
|
232b90ad50e8
(wait_reading_process_input) [! subprocesses]: Run
Karl Heuer <kwzh@gnu.org>
parents:
14802
diff
changeset
|
5144 break; |
|
37413
49147b9fe206
(wait_reading_process_input) [!subprocesses]: Don't
Eli Zaretskii <eliz@gnu.org>
parents:
37398
diff
changeset
|
5145 } |
|
49147b9fe206
(wait_reading_process_input) [!subprocesses]: Don't
Eli Zaretskii <eliz@gnu.org>
parents:
37398
diff
changeset
|
5146 |
|
22535
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5147 /* If there is unread keyboard input, also return. */ |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5148 if (XINT (read_kbd) != 0 |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5149 && requeued_events_pending_p ()) |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5150 break; |
|
fd9324c5a498
(wait_reading_process_input): Recompute timeout each
Eli Zaretskii <eliz@gnu.org>
parents:
22523
diff
changeset
|
5151 |
|
15064
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5152 /* If wait_for_cell. check for keyboard input |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5153 but don't run any timers. |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5154 ??? (It seems wrong to me to check for keyboard |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5155 input at all when wait_for_cell, but the code |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5156 has been this way since July 1994. |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5157 Try changing this after version 19.31.) */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
5158 if (! NILP (wait_for_cell) |
|
15064
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5159 && detect_input_pending ()) |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5160 { |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5161 swallow_events (do_display); |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5162 if (detect_input_pending ()) |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5163 break; |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5164 } |
|
fb0f2804c34a
(wait_reading_process_input, both definitions):
Richard M. Stallman <rms@gnu.org>
parents:
15025
diff
changeset
|
5165 |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5166 /* Exit now if the cell we're waiting for became non-nil. */ |
|
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
39964
diff
changeset
|
5167 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) |
|
15021
af36df262fc5
(wait_reading_process_input) [!subprocesses]: Handle
Richard M. Stallman <rms@gnu.org>
parents:
14998
diff
changeset
|
5168 break; |
| 588 | 5169 } |
| 5170 | |
|
2120
fc3cdca22f8d
* process.c (process_send_signal): In the TERMIOS code for sending
Jim Blandy <jimb@redhat.com>
parents:
1925
diff
changeset
|
5171 start_polling (); |
|
fc3cdca22f8d
* process.c (process_send_signal): In the TERMIOS code for sending
Jim Blandy <jimb@redhat.com>
parents:
1925
diff
changeset
|
5172 |
| 588 | 5173 return 0; |
| 5174 } | |
| 5175 | |
| 5176 | |
|
39964
4ca5cbe5610d
(process-inherit-coding-system-flag, get-buffer-process): Do not confuse
Pavel Jan?k <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
5177 /* Don't confuse make-docfile by having two doc strings for this function. |
|
4ca5cbe5610d
(process-inherit-coding-system-flag, get-buffer-process): Do not confuse
Pavel Jan?k <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
5178 make-docfile does not pay attention to #if, for good reason! */ |
| 588 | 5179 DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0, |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
5180 0) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
5181 (name) |
| 588 | 5182 register Lisp_Object name; |
| 5183 { | |
| 5184 return Qnil; | |
| 5185 } | |
| 5186 | |
|
39964
4ca5cbe5610d
(process-inherit-coding-system-flag, get-buffer-process): Do not confuse
Pavel Jan?k <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
5187 /* Don't confuse make-docfile by having two doc strings for this function. |
|
4ca5cbe5610d
(process-inherit-coding-system-flag, get-buffer-process): Do not confuse
Pavel Jan?k <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
5188 make-docfile does not pay attention to #if, for good reason! */ |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5189 DEFUN ("process-inherit-coding-system-flag", |
|
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
5190 Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
5191 1, 1, 0, |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
5192 0) |
|
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Jan?k <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
5193 (process) |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5194 register Lisp_Object process; |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5195 { |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5196 /* Ignore the argument and return the value of |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5197 inherit-process-coding-system. */ |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5198 return inherit_process_coding_system ? Qt : Qnil; |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5199 } |
|
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5200 |
| 588 | 5201 /* Kill all processes associated with `buffer'. |
| 5202 If `buffer' is nil, kill all processes. | |
| 5203 Since we have no subprocesses, this does nothing. */ | |
| 5204 | |
|
21414
aac7354edaed
(kill_buffer_processes): Make consistent with
Karl Heuer <kwzh@gnu.org>
parents:
21281
diff
changeset
|
5205 void |
| 588 | 5206 kill_buffer_processes (buffer) |
| 5207 Lisp_Object buffer; | |
| 5208 { | |
| 5209 } | |
| 5210 | |
|
21978
ba8852d809f6
(init_process, syms_of_process): Make definition consistent with
Eli Zaretskii <eliz@gnu.org>
parents:
21950
diff
changeset
|
5211 void |
| 588 | 5212 init_process () |
| 5213 { | |
| 5214 } | |
| 5215 | |
|
21978
ba8852d809f6
(init_process, syms_of_process): Make definition consistent with
Eli Zaretskii <eliz@gnu.org>
parents:
21950
diff
changeset
|
5216 void |
| 588 | 5217 syms_of_process () |
| 5218 { | |
| 5219 defsubr (&Sget_buffer_process); | |
|
21656
bb39a5863a82
(Fset_process_inherit_coding_system_flag,
Eli Zaretskii <eliz@gnu.org>
parents:
21530
diff
changeset
|
5220 defsubr (&Sprocess_inherit_coding_system_flag); |
| 588 | 5221 } |
| 5222 | |
| 5223 | |
| 5224 #endif /* not subprocesses */ |
