aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/process.c b/src/process.c
index c803d69d6d8..892a5aa86c5 100644
--- a/src/process.c
+++ b/src/process.c
@@ -361,6 +361,12 @@ static struct sockaddr_and_len {
361#define DATAGRAM_CONN_P(proc) (0) 361#define DATAGRAM_CONN_P(proc) (0)
362#endif 362#endif
363 363
364/* FOR_EACH_PROCESS (LIST_VAR, PROC_VAR) followed by a statement is
365 a `for' loop which iterates over processes from Vprocess_alist. */
366
367#define FOR_EACH_PROCESS(list_var, proc_var) \
368 FOR_EACH_ALIST_VALUE (Vprocess_alist, list_var, proc_var)
369
364/* These setters are used only in this file, so they can be private. */ 370/* These setters are used only in this file, so they can be private. */
365static void 371static void
366pset_buffer (struct Lisp_Process *p, Lisp_Object val) 372pset_buffer (struct Lisp_Process *p, Lisp_Object val)
@@ -6135,7 +6141,7 @@ static signal_handler_t volatile lib_child_handler;
6135static void 6141static void
6136handle_child_signal (int sig) 6142handle_child_signal (int sig)
6137{ 6143{
6138 Lisp_Object tail; 6144 Lisp_Object tail, proc;
6139 6145
6140 /* Find the process that signaled us, and record its status. */ 6146 /* Find the process that signaled us, and record its status. */
6141 6147
@@ -6165,9 +6171,8 @@ handle_child_signal (int sig)
6165 } 6171 }
6166 6172
6167 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ 6173 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */
6168 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) 6174 FOR_EACH_PROCESS (tail, proc)
6169 { 6175 {
6170 Lisp_Object proc = XCDR (XCAR (tail));
6171 struct Lisp_Process *p = XPROCESS (proc); 6176 struct Lisp_Process *p = XPROCESS (proc);
6172 int status; 6177 int status;
6173 6178
@@ -6322,13 +6327,10 @@ status_notify (struct Lisp_Process *deleting_process)
6322 that we run, we get called again to handle their status changes. */ 6327 that we run, we get called again to handle their status changes. */
6323 update_tick = process_tick; 6328 update_tick = process_tick;
6324 6329
6325 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) 6330 FOR_EACH_PROCESS (tail, proc)
6326 { 6331 {
6327 Lisp_Object symbol; 6332 Lisp_Object symbol;
6328 register struct Lisp_Process *p; 6333 register struct Lisp_Process *p = XPROCESS (proc);
6329
6330 proc = Fcdr (XCAR (tail));
6331 p = XPROCESS (proc);
6332 6334
6333 if (p->tick != p->update_tick) 6335 if (p->tick != p->update_tick)
6334 { 6336 {
@@ -6851,12 +6853,9 @@ BUFFER may be a buffer or the name of one. */)
6851 buf = Fget_buffer (buffer); 6853 buf = Fget_buffer (buffer);
6852 if (NILP (buf)) return Qnil; 6854 if (NILP (buf)) return Qnil;
6853 6855
6854 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) 6856 FOR_EACH_PROCESS (tail, proc)
6855 { 6857 if (EQ (XPROCESS (proc)->buffer, buf))
6856 proc = Fcdr (XCAR (tail)); 6858 return proc;
6857 if (PROCESSP (proc) && EQ (XPROCESS (proc)->buffer, buf))
6858 return proc;
6859 }
6860#endif /* subprocesses */ 6859#endif /* subprocesses */
6861 return Qnil; 6860 return Qnil;
6862} 6861}
@@ -6889,18 +6888,14 @@ kill_buffer_processes (Lisp_Object buffer)
6889#ifdef subprocesses 6888#ifdef subprocesses
6890 Lisp_Object tail, proc; 6889 Lisp_Object tail, proc;
6891 6890
6892 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) 6891 FOR_EACH_PROCESS (tail, proc)
6893 { 6892 if (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))
6894 proc = XCDR (XCAR (tail)); 6893 {
6895 if (PROCESSP (proc) 6894 if (NETCONN_P (proc) || SERIALCONN_P (proc))
6896 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) 6895 Fdelete_process (proc);
6897 { 6896 else if (XPROCESS (proc)->infd >= 0)
6898 if (NETCONN_P (proc) || SERIALCONN_P (proc)) 6897 process_send_signal (proc, SIGHUP, Qnil, 1);
6899 Fdelete_process (proc); 6898 }
6900 else if (XPROCESS (proc)->infd >= 0)
6901 process_send_signal (proc, SIGHUP, Qnil, 1);
6902 }
6903 }
6904#else /* subprocesses */ 6899#else /* subprocesses */
6905 /* Since we have no subprocesses, this does nothing. */ 6900 /* Since we have no subprocesses, this does nothing. */
6906#endif /* subprocesses */ 6901#endif /* subprocesses */