aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.h
diff options
context:
space:
mode:
authorEli Zaretskii2013-09-05 11:01:04 +0300
committerEli Zaretskii2013-09-05 11:01:04 +0300
commit41306318777a942420bc4feadbfacf662ea179dc (patch)
tree669e5cca02f95d6064ce73c0d3fbbf91b8c8b563 /src/process.h
parent141f1ff7a40cda10f0558e891dd196a943a5082e (diff)
parent257b3b03cb1cff917e0b3b7832ad3eab5b59f257 (diff)
downloademacs-41306318777a942420bc4feadbfacf662ea179dc.tar.gz
emacs-41306318777a942420bc4feadbfacf662ea179dc.zip
Merge from trunk after a lot of time.
Diffstat (limited to 'src/process.h')
-rw-r--r--src/process.h113
1 files changed, 82 insertions, 31 deletions
diff --git a/src/process.h b/src/process.h
index edb937893b0..6aff95686a2 100644
--- a/src/process.h
+++ b/src/process.h
@@ -1,5 +1,5 @@
1/* Definitions for asynchronous process control in GNU Emacs. 1/* Definitions for asynchronous process control in GNU Emacs.
2 Copyright (C) 1985, 1994, 2001-2012 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1994, 2001-2013 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -26,11 +26,18 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include "gnutls.h" 26#include "gnutls.h"
27#endif 27#endif
28 28
29/* This structure records information about a subprocess 29INLINE_HEADER_BEGIN
30 or network connection. 30#ifndef PROCESS_INLINE
31# define PROCESS_INLINE INLINE
32#endif
31 33
32 Every field in this structure except for the header 34/* Bound on number of file descriptors opened on behalf of a process,
33 must be a Lisp_Object, for GC's sake. */ 35 that need to be closed. */
36
37enum { PROCESS_OPEN_FDS = 6 };
38
39/* This structure records information about a subprocess
40 or network connection. */
34 41
35struct Lisp_Process 42struct Lisp_Process
36 { 43 {
@@ -38,46 +45,65 @@ struct Lisp_Process
38 45
39 /* Name of subprocess terminal. */ 46 /* Name of subprocess terminal. */
40 Lisp_Object tty_name; 47 Lisp_Object tty_name;
48
41 /* Name of this process */ 49 /* Name of this process */
42 Lisp_Object name; 50 Lisp_Object name;
51
43 /* List of command arguments that this process was run with. 52 /* List of command arguments that this process was run with.
44 Is set to t for a stopped network process; nil otherwise. */ 53 Is set to t for a stopped network process; nil otherwise. */
45 Lisp_Object command; 54 Lisp_Object command;
55
46 /* (funcall FILTER PROC STRING) (if FILTER is non-nil) 56 /* (funcall FILTER PROC STRING) (if FILTER is non-nil)
47 to dispose of a bunch of chars from the process all at once */ 57 to dispose of a bunch of chars from the process all at once */
48 Lisp_Object filter; 58 Lisp_Object filter;
59
49 /* (funcall SENTINEL PROCESS) when process state changes */ 60 /* (funcall SENTINEL PROCESS) when process state changes */
50 Lisp_Object sentinel; 61 Lisp_Object sentinel;
62
51 /* (funcall LOG SERVER CLIENT MESSAGE) when a server process 63 /* (funcall LOG SERVER CLIENT MESSAGE) when a server process
52 accepts a connection from a client. */ 64 accepts a connection from a client. */
53 Lisp_Object log; 65 Lisp_Object log;
66
54 /* Buffer that output is going to */ 67 /* Buffer that output is going to */
55 Lisp_Object buffer; 68 Lisp_Object buffer;
69
56 /* t if this is a real child process. For a network or serial 70 /* t if this is a real child process. For a network or serial
57 connection, it is a plist based on the arguments to 71 connection, it is a plist based on the arguments to
58 make-network-process or make-serial-process. */ 72 make-network-process or make-serial-process. */
73
59 Lisp_Object childp; 74 Lisp_Object childp;
75
60 /* Plist for programs to keep per-process state information, parameters, etc. */ 76 /* Plist for programs to keep per-process state information, parameters, etc. */
61 Lisp_Object plist; 77 Lisp_Object plist;
78
62 /* Symbol indicating the type of process: real, network, serial */ 79 /* Symbol indicating the type of process: real, network, serial */
63 Lisp_Object type; 80 Lisp_Object type;
81
64 /* Marker set to end of last buffer-inserted output from this process */ 82 /* Marker set to end of last buffer-inserted output from this process */
65 Lisp_Object mark; 83 Lisp_Object mark;
84
66 /* Symbol indicating status of process. 85 /* Symbol indicating status of process.
67 This may be a symbol: run, open, or closed. 86 This may be a symbol: run, open, or closed.
68 Or it may be a list, whose car is stop, exit or signal 87 Or it may be a list, whose car is stop, exit or signal
69 and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG) 88 and whose cdr is a pair (EXIT_CODE . COREDUMP_FLAG)
70 or (SIGNAL_NUMBER . COREDUMP_FLAG). */ 89 or (SIGNAL_NUMBER . COREDUMP_FLAG). */
71 Lisp_Object status; 90 Lisp_Object status;
91
72 /* Coding-system for decoding the input from this process. */ 92 /* Coding-system for decoding the input from this process. */
73 Lisp_Object decode_coding_system; 93 Lisp_Object decode_coding_system;
94
74 /* Working buffer for decoding. */ 95 /* Working buffer for decoding. */
75 Lisp_Object decoding_buf; 96 Lisp_Object decoding_buf;
97
76 /* Coding-system for encoding the output to this process. */ 98 /* Coding-system for encoding the output to this process. */
77 Lisp_Object encode_coding_system; 99 Lisp_Object encode_coding_system;
100
78 /* Working buffer for encoding. */ 101 /* Working buffer for encoding. */
79 Lisp_Object encoding_buf; 102 Lisp_Object encoding_buf;
80 103
104 /* Queue for storing waiting writes */
105 Lisp_Object write_queue;
106
81#ifdef HAVE_GNUTLS 107#ifdef HAVE_GNUTLS
82 Lisp_Object gnutls_cred_type; 108 Lisp_Object gnutls_cred_type;
83#endif 109#endif
@@ -94,6 +120,9 @@ struct Lisp_Process
94 int infd; 120 int infd;
95 /* Descriptor by which we write to this process */ 121 /* Descriptor by which we write to this process */
96 int outfd; 122 int outfd;
123 /* Descriptors that were created for this process and that need
124 closing. Unused entries are negative. */
125 int open_fd[PROCESS_OPEN_FDS];
97 /* Event-count of last event in which this process changed status. */ 126 /* Event-count of last event in which this process changed status. */
98 EMACS_INT tick; 127 EMACS_INT tick;
99 /* Event-count of last such event reported. */ 128 /* Event-count of last such event reported. */
@@ -104,8 +133,8 @@ struct Lisp_Process
104 On some systems, e.g. GNU/Linux, Emacs is seen as 133 On some systems, e.g. GNU/Linux, Emacs is seen as
105 an interactive app also when reading process output, meaning 134 an interactive app also when reading process output, meaning
106 that process output can be read in as little as 1 byte at a 135 that process output can be read in as little as 1 byte at a
107 time. Value is micro-seconds to delay reading output from 136 time. Value is nanoseconds to delay reading output from
108 this process. Range is 0 .. 50000. */ 137 this process. Range is 0 .. 50 * 1000 * 1000. */
109 int read_output_delay; 138 int read_output_delay;
110 /* Should we delay reading output from this process. 139 /* Should we delay reading output from this process.
111 Initialized from `Vprocess_adaptive_read_buffering'. 140 Initialized from `Vprocess_adaptive_read_buffering'.
@@ -121,6 +150,9 @@ struct Lisp_Process
121 /* Flag to set coding-system of the process buffer from the 150 /* Flag to set coding-system of the process buffer from the
122 coding_system used to decode process output. */ 151 coding_system used to decode process output. */
123 unsigned int inherit_coding_system_flag : 1; 152 unsigned int inherit_coding_system_flag : 1;
153 /* Whether the process is alive, i.e., can be waited for. Running
154 processes can be waited for, but exited and fake processes cannot. */
155 unsigned int alive : 1;
124 /* Record the process status in the raw form in which it comes from `wait'. 156 /* Record the process status in the raw form in which it comes from `wait'.
125 This is to avoid consing in a signal handler. The `raw_status_new' 157 This is to avoid consing in a signal handler. The `raw_status_new'
126 flag indicates that `raw_status' contains a new status that still 158 flag indicates that `raw_status' contains a new status that still
@@ -135,7 +167,7 @@ struct Lisp_Process
135 gnutls_anon_client_credentials_t gnutls_anon_cred; 167 gnutls_anon_client_credentials_t gnutls_anon_cred;
136 int gnutls_log_level; 168 int gnutls_log_level;
137 int gnutls_handshakes_tried; 169 int gnutls_handshakes_tried;
138 int gnutls_p; 170 unsigned int gnutls_p : 1;
139#endif 171#endif
140}; 172};
141 173
@@ -144,32 +176,26 @@ struct Lisp_Process
144 176
145#define ChannelMask(n) (1 << (n)) 177#define ChannelMask(n) (1 << (n))
146 178
147/* True if we are about to fork off a synchronous process or if we 179/* Most code should use these functions to set Lisp fields in struct
148 are waiting for it. */ 180 process. */
149extern int synch_process_alive;
150 181
151/* Communicate exit status of sync process to from sigchld_handler 182PROCESS_INLINE void
152 to Fcall_process. */ 183pset_childp (struct Lisp_Process *p, Lisp_Object val)
184{
185 p->childp = val;
186}
153 187
154/* Nonzero => this is a string explaining death of synchronous subprocess. */ 188#ifdef HAVE_GNUTLS
155extern const char *synch_process_death; 189PROCESS_INLINE void
156 190pset_gnutls_cred_type (struct Lisp_Process *p, Lisp_Object val)
157/* Nonzero => this is the signal number that terminated the subprocess. */ 191{
158extern int synch_process_termsig; 192 p->gnutls_cred_type = val;
159 193}
160/* If synch_process_death is zero,
161 this is exit code of synchronous subprocess. */
162extern int synch_process_retcode;
163
164/* The name of the file open to get a null file, or a data sink.
165 MS-DOS, and OS/2 redefine this. */
166#ifndef NULL_DEVICE
167#define NULL_DEVICE "/dev/null"
168#endif 194#endif
169 195
170/* Nonzero means don't run process sentinels. This is used 196/* True means don't run process sentinels. This is used
171 when exiting. */ 197 when exiting. */
172extern int inhibit_sentinels; 198extern bool inhibit_sentinels;
173 199
174extern Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname; 200extern Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname;
175extern Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime; 201extern Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime;
@@ -180,16 +206,41 @@ extern Lisp_Object QCspeed;
180extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; 206extern Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven;
181extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; 207extern Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary;
182 208
209/* Exit statuses for GNU programs that exec other programs. */
210enum
211{
212 EXIT_CANCELED = 125, /* Internal error prior to exec attempt. */
213 EXIT_CANNOT_INVOKE = 126, /* Program located, but not usable. */
214 EXIT_ENOENT = 127 /* Could not find program to exec. */
215};
216
217/* Defined in callproc.c. */
218
219extern void block_child_signal (void);
220extern void unblock_child_signal (void);
221extern Lisp_Object encode_current_directory (void);
222extern void record_kill_process (struct Lisp_Process *, Lisp_Object);
223
224/* Defined in sysdep.c. */
225
183extern Lisp_Object list_system_processes (void); 226extern Lisp_Object list_system_processes (void);
184extern Lisp_Object system_process_attributes (Lisp_Object); 227extern Lisp_Object system_process_attributes (Lisp_Object);
185 228
229/* Defined in process.c. */
230
231extern void record_deleted_pid (pid_t, Lisp_Object);
186extern void hold_keyboard_input (void); 232extern void hold_keyboard_input (void);
187extern void unhold_keyboard_input (void); 233extern void unhold_keyboard_input (void);
188extern int kbd_on_hold_p (void); 234extern bool kbd_on_hold_p (void);
189 235
190typedef void (*fd_callback)(int fd, void *data, int for_read); 236typedef void (*fd_callback) (int fd, void *data);
191 237
192extern void add_read_fd (int fd, fd_callback func, void *data); 238extern void add_read_fd (int fd, fd_callback func, void *data);
193extern void delete_read_fd (int fd); 239extern void delete_read_fd (int fd);
194extern void add_write_fd (int fd, fd_callback func, void *data); 240extern void add_write_fd (int fd, fd_callback func, void *data);
195extern void delete_write_fd (int fd); 241extern void delete_write_fd (int fd);
242#ifdef NS_IMPL_GNUSTEP
243extern void catch_child_signal (void);
244#endif
245
246INLINE_HEADER_END