Mercurial > hg > xemacs-beta
comparison src/process.c @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | 3ecd8885ac67 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
56 #include "systime.h" | 56 #include "systime.h" |
57 #include "syssignal.h" /* Always include before systty.h */ | 57 #include "syssignal.h" /* Always include before systty.h */ |
58 #include "systty.h" | 58 #include "systty.h" |
59 #include "syswait.h" | 59 #include "syswait.h" |
60 | 60 |
61 Lisp_Object Qprocessp; | 61 Lisp_Object Qprocessp, Qprocess_live_p; |
62 | 62 |
63 /* Process methods */ | 63 /* Process methods */ |
64 struct process_methods the_process_methods; | 64 struct process_methods the_process_methods; |
65 | 65 |
66 /* a process object is a network connection when its pid field a cons | 66 /* a process object is a network connection when its pid field a cons |
111 | 111 |
112 | 112 |
113 static Lisp_Object | 113 static Lisp_Object |
114 mark_process (Lisp_Object obj) | 114 mark_process (Lisp_Object obj) |
115 { | 115 { |
116 struct Lisp_Process *proc = XPROCESS (obj); | 116 Lisp_Process *proc = XPROCESS (obj); |
117 MAYBE_PROCMETH (mark_process_data, (proc)); | 117 MAYBE_PROCMETH (mark_process_data, (proc)); |
118 mark_object (proc->name); | 118 mark_object (proc->name); |
119 mark_object (proc->command); | 119 mark_object (proc->command); |
120 mark_object (proc->filter); | 120 mark_object (proc->filter); |
121 mark_object (proc->sentinel); | 121 mark_object (proc->sentinel); |
132 } | 132 } |
133 | 133 |
134 static void | 134 static void |
135 print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) | 135 print_process (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) |
136 { | 136 { |
137 struct Lisp_Process *proc = XPROCESS (obj); | 137 Lisp_Process *proc = XPROCESS (obj); |
138 | 138 |
139 if (print_readably) | 139 if (print_readably) |
140 error ("printing unreadable object #<process %s>", | 140 error ("printing unreadable object #<process %s>", |
141 XSTRING_DATA (proc->name)); | 141 XSTRING_DATA (proc->name)); |
142 | 142 |
158 write_c_string (">", printcharfun); | 158 write_c_string (">", printcharfun); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 #ifdef HAVE_WINDOW_SYSTEM | 162 #ifdef HAVE_WINDOW_SYSTEM |
163 extern void debug_process_finalization (struct Lisp_Process *p); | 163 extern void debug_process_finalization (Lisp_Process *p); |
164 #endif /* HAVE_WINDOW_SYSTEM */ | 164 #endif /* HAVE_WINDOW_SYSTEM */ |
165 | 165 |
166 static void | 166 static void |
167 finalize_process (void *header, int for_disksave) | 167 finalize_process (void *header, int for_disksave) |
168 { | 168 { |
169 /* #### this probably needs to be tied into the tty event loop */ | 169 /* #### this probably needs to be tied into the tty event loop */ |
170 /* #### when there is one */ | 170 /* #### when there is one */ |
171 struct Lisp_Process *p = (struct Lisp_Process *) header; | 171 Lisp_Process *p = (Lisp_Process *) header; |
172 #ifdef HAVE_WINDOW_SYSTEM | 172 #ifdef HAVE_WINDOW_SYSTEM |
173 if (!for_disksave) | 173 if (!for_disksave) |
174 { | 174 { |
175 debug_process_finalization (p); | 175 debug_process_finalization (p); |
176 } | 176 } |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 DEFINE_LRECORD_IMPLEMENTATION ("process", process, | 187 DEFINE_LRECORD_IMPLEMENTATION ("process", process, |
188 mark_process, print_process, finalize_process, | 188 mark_process, print_process, finalize_process, |
189 0, 0, 0, struct Lisp_Process); | 189 0, 0, 0, Lisp_Process); |
190 | 190 |
191 /************************************************************************/ | 191 /************************************************************************/ |
192 /* basic process accessors */ | 192 /* basic process accessors */ |
193 /************************************************************************/ | 193 /************************************************************************/ |
194 | 194 |
195 /* Under FILE_CODING, this function returns low-level streams, connected | 195 /* Under FILE_CODING, this function returns low-level streams, connected |
196 directly to the child process, rather than en/decoding FILE_CODING | 196 directly to the child process, rather than en/decoding FILE_CODING |
197 streams */ | 197 streams */ |
198 void | 198 void |
199 get_process_streams (struct Lisp_Process *p, | 199 get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr) |
200 Lisp_Object *instr, Lisp_Object *outstr) | |
201 { | 200 { |
202 assert (p); | 201 assert (p); |
203 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream)); | 202 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream)); |
204 assert (NILP (p->pipe_outstream) || LSTREAMP(p->pipe_outstream)); | 203 assert (NILP (p->pipe_outstream) || LSTREAMP(p->pipe_outstream)); |
205 *instr = p->pipe_instream; | 204 *instr = p->pipe_instream; |
206 *outstr = p->pipe_outstream; | 205 *outstr = p->pipe_outstream; |
207 } | 206 } |
208 | 207 |
209 struct Lisp_Process * | 208 Lisp_Process * |
210 get_process_from_usid (USID usid) | 209 get_process_from_usid (USID usid) |
211 { | 210 { |
212 CONST void *vval; | 211 CONST void *vval; |
213 | 212 |
214 assert (usid != USID_ERROR && usid != USID_DONTHASH); | 213 assert (usid != USID_ERROR && usid != USID_DONTHASH); |
222 else | 221 else |
223 return 0; | 222 return 0; |
224 } | 223 } |
225 | 224 |
226 int | 225 int |
227 get_process_selected_p (struct Lisp_Process *p) | 226 get_process_selected_p (Lisp_Process *p) |
228 { | 227 { |
229 return p->selected; | 228 return p->selected; |
230 } | 229 } |
231 | 230 |
232 void | 231 void |
233 set_process_selected_p (struct Lisp_Process *p, int selected_p) | 232 set_process_selected_p (Lisp_Process *p, int selected_p) |
234 { | 233 { |
235 p->selected = !!selected_p; | 234 p->selected = !!selected_p; |
236 } | 235 } |
237 | 236 |
238 int | 237 int |
239 connected_via_filedesc_p (struct Lisp_Process *p) | 238 connected_via_filedesc_p (Lisp_Process *p) |
240 { | 239 { |
241 return MAYBE_INT_PROCMETH (tooltalk_connection_p, (p)); | 240 return MAYBE_INT_PROCMETH (tooltalk_connection_p, (p)); |
242 } | 241 } |
243 | 242 |
244 #ifdef HAVE_SOCKETS | 243 #ifdef HAVE_SOCKETS |
253 Return t if OBJECT is a process. | 252 Return t if OBJECT is a process. |
254 */ | 253 */ |
255 (obj)) | 254 (obj)) |
256 { | 255 { |
257 return PROCESSP (obj) ? Qt : Qnil; | 256 return PROCESSP (obj) ? Qt : Qnil; |
257 } | |
258 | |
259 DEFUN ("process-live-p", Fprocess_live_p, 1, 1, 0, /* | |
260 Return t if OBJECT is a process that is alive. | |
261 */ | |
262 (obj)) | |
263 { | |
264 return PROCESSP (obj) && PROCESS_LIVE_P (XPROCESS (obj)) ? Qt : Qnil; | |
258 } | 265 } |
259 | 266 |
260 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /* | 267 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /* |
261 Return a list of all processes. | 268 Return a list of all processes. |
262 */ | 269 */ |
414 Lisp_Object | 421 Lisp_Object |
415 make_process_internal (Lisp_Object name) | 422 make_process_internal (Lisp_Object name) |
416 { | 423 { |
417 Lisp_Object val, name1; | 424 Lisp_Object val, name1; |
418 int i; | 425 int i; |
419 struct Lisp_Process *p = | 426 Lisp_Process *p = alloc_lcrecord_type (Lisp_Process, &lrecord_process); |
420 alloc_lcrecord_type (struct Lisp_Process, &lrecord_process); | |
421 | 427 |
422 /* If name is already in use, modify it until it is unused. */ | 428 /* If name is already in use, modify it until it is unused. */ |
423 name1 = name; | 429 name1 = name; |
424 for (i = 1; ; i++) | 430 for (i = 1; ; i++) |
425 { | 431 { |
462 Vprocess_list = Fcons (val, Vprocess_list); | 468 Vprocess_list = Fcons (val, Vprocess_list); |
463 return val; | 469 return val; |
464 } | 470 } |
465 | 471 |
466 void | 472 void |
467 init_process_io_handles (struct Lisp_Process *p, void* in, void* out, int flags) | 473 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags) |
468 { | 474 { |
469 USID usid = event_stream_create_stream_pair (in, out, | 475 USID usid = event_stream_create_stream_pair (in, out, |
470 &p->pipe_instream, &p->pipe_outstream, | 476 &p->pipe_instream, &p->pipe_outstream, |
471 flags); | 477 flags); |
472 | 478 |
497 | 503 |
498 static void | 504 static void |
499 create_process (Lisp_Object process, Lisp_Object *argv, int nargv, | 505 create_process (Lisp_Object process, Lisp_Object *argv, int nargv, |
500 Lisp_Object program, Lisp_Object cur_dir) | 506 Lisp_Object program, Lisp_Object cur_dir) |
501 { | 507 { |
502 struct Lisp_Process *p = XPROCESS (process); | 508 Lisp_Process *p = XPROCESS (process); |
503 int pid; | 509 int pid; |
504 | 510 |
505 /* *_create_process may change status_symbol, if the process | 511 /* *_create_process may change status_symbol, if the process |
506 is a kind of "fire-and-forget" (no I/O, unwaitable) */ | 512 is a kind of "fire-and-forget" (no I/O, unwaitable) */ |
507 p->status_symbol = Qrun; | 513 p->status_symbol = Qrun; |
508 p->exit_code = 0; | 514 p->exit_code = 0; |
509 | 515 |
510 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir)); | 516 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir)); |
511 | 517 |
512 p->pid = make_int (pid); | 518 p->pid = make_int (pid); |
513 if (!NILP(p->pipe_instream)) | 519 if (PROCESS_LIVE_P (p)) |
514 event_stream_select_process (p); | 520 event_stream_select_process (p); |
515 } | 521 } |
516 | 522 |
517 /* This function is the unwind_protect form for Fstart_process_internal. If | 523 /* This function is the unwind_protect form for Fstart_process_internal. If |
518 PROC doesn't have its pid set, then we know someone has signalled | 524 PROC doesn't have its pid set, then we know someone has signalled |
811 { | 817 { |
812 /* This function can GC */ | 818 /* This function can GC */ |
813 Bytecount nbytes, nchars; | 819 Bytecount nbytes, nchars; |
814 Bufbyte chars[1024]; | 820 Bufbyte chars[1024]; |
815 Lisp_Object outstream; | 821 Lisp_Object outstream; |
816 struct Lisp_Process *p = XPROCESS (proc); | 822 Lisp_Process *p = XPROCESS (proc); |
817 | 823 |
818 /* If there is a lot of output from the subprocess, the loop in | 824 /* If there is a lot of output from the subprocess, the loop in |
819 execute_internal_event() might call read_process_output() more | 825 execute_internal_event() might call read_process_output() more |
820 than once. If the filter that was executed from one of these | 826 than once. If the filter that was executed from one of these |
821 calls set the filter to t, we have to stop now. Return -1 rather | 827 calls set the filter to t, we have to stop now. Return -1 rather |
822 than 0 so execute_internal_event() doesn't close the process. | 828 than 0 so execute_internal_event() doesn't close the process. |
823 Really, the loop in execute_internal_event() should check itself | 829 Really, the loop in execute_internal_event() should check itself |
824 for a process-filter change, like in status_notify(); but the | 830 for a process-filter change, like in status_notify(); but the |
825 struct Lisp_Process is not exported outside of this file. */ | 831 struct Lisp_Process is not exported outside of this file. */ |
826 if (NILP(p->pipe_instream)) | 832 if (!PROCESS_LIVE_P (p)) |
827 return -1; /* already closed */ | 833 return -1; /* already closed */ |
828 | 834 |
829 if (!NILP (p->filter) && (p->filter_does_read)) | 835 if (!NILP (p->filter) && (p->filter_does_read)) |
830 { | 836 { |
831 Lisp_Object filter_result; | 837 Lisp_Object filter_result; |
1030 | 1036 |
1031 void | 1037 void |
1032 set_process_filter (Lisp_Object proc, Lisp_Object filter, int filter_does_read) | 1038 set_process_filter (Lisp_Object proc, Lisp_Object filter, int filter_does_read) |
1033 { | 1039 { |
1034 CHECK_PROCESS (proc); | 1040 CHECK_PROCESS (proc); |
1035 if (PROCESS_LIVE_P (proc)) { | 1041 if (PROCESS_LIVE_P (XPROCESS (proc))) { |
1036 if (EQ (filter, Qt)) | 1042 if (EQ (filter, Qt)) |
1037 event_stream_unselect_process (XPROCESS (proc)); | 1043 event_stream_unselect_process (XPROCESS (proc)); |
1038 else | 1044 else |
1039 event_stream_select_process (XPROCESS (proc)); | 1045 event_stream_select_process (XPROCESS (proc)); |
1040 } | 1046 } |
1119 Return PROCESS's input coding system. | 1125 Return PROCESS's input coding system. |
1120 */ | 1126 */ |
1121 (process)) | 1127 (process)) |
1122 { | 1128 { |
1123 process = get_process (process); | 1129 process = get_process (process); |
1130 CHECK_LIVE_PROCESS (process); | |
1124 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) ); | 1131 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) ); |
1125 } | 1132 } |
1126 | 1133 |
1127 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* | 1134 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* |
1128 Return PROCESS's output coding system. | 1135 Return PROCESS's output coding system. |
1129 */ | 1136 */ |
1130 (process)) | 1137 (process)) |
1131 { | 1138 { |
1132 process = get_process (process); | 1139 process = get_process (process); |
1140 CHECK_LIVE_PROCESS (process); | |
1133 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream)); | 1141 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream)); |
1134 } | 1142 } |
1135 | 1143 |
1136 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* | 1144 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* |
1137 Return a pair of coding-system for decoding and encoding of PROCESS. | 1145 Return a pair of coding-system for decoding and encoding of PROCESS. |
1138 */ | 1146 */ |
1139 (process)) | 1147 (process)) |
1140 { | 1148 { |
1141 process = get_process (process); | 1149 process = get_process (process); |
1150 CHECK_LIVE_PROCESS (process); | |
1142 return Fcons (decoding_stream_coding_system | 1151 return Fcons (decoding_stream_coding_system |
1143 (XLSTREAM (XPROCESS (process)->coding_instream)), | 1152 (XLSTREAM (XPROCESS (process)->coding_instream)), |
1144 encoding_stream_coding_system | 1153 encoding_stream_coding_system |
1145 (XLSTREAM (XPROCESS (process)->coding_outstream))); | 1154 (XLSTREAM (XPROCESS (process)->coding_outstream))); |
1146 } | 1155 } |
1151 */ | 1160 */ |
1152 (process, codesys)) | 1161 (process, codesys)) |
1153 { | 1162 { |
1154 codesys = Fget_coding_system (codesys); | 1163 codesys = Fget_coding_system (codesys); |
1155 process = get_process (process); | 1164 process = get_process (process); |
1165 CHECK_LIVE_PROCESS (process); | |
1166 | |
1156 set_decoding_stream_coding_system | 1167 set_decoding_stream_coding_system |
1157 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); | 1168 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); |
1158 return Qnil; | 1169 return Qnil; |
1159 } | 1170 } |
1160 | 1171 |
1164 */ | 1175 */ |
1165 (process, codesys)) | 1176 (process, codesys)) |
1166 { | 1177 { |
1167 codesys = Fget_coding_system (codesys); | 1178 codesys = Fget_coding_system (codesys); |
1168 process = get_process (process); | 1179 process = get_process (process); |
1180 CHECK_LIVE_PROCESS (process); | |
1181 | |
1169 set_encoding_stream_coding_system | 1182 set_encoding_stream_coding_system |
1170 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); | 1183 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); |
1171 return Qnil; | 1184 return Qnil; |
1172 } | 1185 } |
1173 | 1186 |
1174 DEFUN ("set-process-coding-system", Fset_process_coding_system, | 1187 DEFUN ("set-process-coding-system", Fset_process_coding_system, |
1175 1, 3, 0, /* | 1188 1, 3, 0, /* |
1176 Set coding-systems of PROCESS to DECODING and ENCODING. | 1189 Set coding-systems of PROCESS to DECODING and ENCODING. |
1190 DECODING will be used to decode subprocess output and ENCODING to | |
1191 encode subprocess input. | |
1177 */ | 1192 */ |
1178 (process, decoding, encoding)) | 1193 (process, decoding, encoding)) |
1179 { | 1194 { |
1180 if (!NILP (decoding)) | 1195 if (!NILP (decoding)) |
1181 Fset_process_input_coding_system (process, decoding); | 1196 Fset_process_input_coding_system (process, decoding); |
1193 /************************************************************************/ | 1208 /************************************************************************/ |
1194 | 1209 |
1195 static Lisp_Object | 1210 static Lisp_Object |
1196 exec_sentinel_unwind (Lisp_Object datum) | 1211 exec_sentinel_unwind (Lisp_Object datum) |
1197 { | 1212 { |
1198 struct Lisp_Cons *d = XCONS (datum); | 1213 Lisp_Cons *d = XCONS (datum); |
1199 XPROCESS (d->car)->sentinel = d->cdr; | 1214 XPROCESS (d->car)->sentinel = d->cdr; |
1200 free_cons (d); | 1215 free_cons (d); |
1201 return Qnil; | 1216 return Qnil; |
1202 } | 1217 } |
1203 | 1218 |
1204 static void | 1219 static void |
1205 exec_sentinel (Lisp_Object proc, Lisp_Object reason) | 1220 exec_sentinel (Lisp_Object proc, Lisp_Object reason) |
1206 { | 1221 { |
1207 /* This function can GC */ | 1222 /* This function can GC */ |
1208 int speccount = specpdl_depth (); | 1223 int speccount = specpdl_depth (); |
1209 struct Lisp_Process *p = XPROCESS (proc); | 1224 Lisp_Process *p = XPROCESS (proc); |
1210 Lisp_Object sentinel = p->sentinel; | 1225 Lisp_Object sentinel = p->sentinel; |
1211 | 1226 |
1212 if (NILP (sentinel)) | 1227 if (NILP (sentinel)) |
1213 return; | 1228 return; |
1214 | 1229 |
1274 } | 1289 } |
1275 | 1290 |
1276 /* Return a string describing a process status list. */ | 1291 /* Return a string describing a process status list. */ |
1277 | 1292 |
1278 static Lisp_Object | 1293 static Lisp_Object |
1279 status_message (struct Lisp_Process *p) | 1294 status_message (Lisp_Process *p) |
1280 { | 1295 { |
1281 Lisp_Object symbol = p->status_symbol; | 1296 Lisp_Object symbol = p->status_symbol; |
1282 int code = p->exit_code; | 1297 int code = p->exit_code; |
1283 int coredump = p->core_dumped; | 1298 int coredump = p->core_dumped; |
1284 Lisp_Object string, string2; | 1299 Lisp_Object string, string2; |
1358 GCPRO3 (tail, symbol, msg); | 1373 GCPRO3 (tail, symbol, msg); |
1359 | 1374 |
1360 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail)) | 1375 for (tail = Vprocess_list; CONSP (tail); tail = XCDR (tail)) |
1361 { | 1376 { |
1362 Lisp_Object proc = XCAR (tail); | 1377 Lisp_Object proc = XCAR (tail); |
1363 struct Lisp_Process *p = XPROCESS (proc); | 1378 Lisp_Process *p = XPROCESS (proc); |
1364 /* p->tick is also volatile. Same thing as above applies. */ | 1379 /* p->tick is also volatile. Same thing as above applies. */ |
1365 int this_process_tick; | 1380 int this_process_tick; |
1366 | 1381 |
1367 /* #### extra check for terminated processes, in case a SIGCHLD | 1382 /* #### extra check for terminated processes, in case a SIGCHLD |
1368 got missed (this seems to happen sometimes, I'm not sure why). | 1383 got missed (this seems to happen sometimes, I'm not sure why). |
1525 Lisp_Object proc = get_process (process); | 1540 Lisp_Object proc = get_process (process); |
1526 | 1541 |
1527 if (network_connection_p (proc)) | 1542 if (network_connection_p (proc)) |
1528 error ("Network connection %s is not a subprocess", | 1543 error ("Network connection %s is not a subprocess", |
1529 XSTRING_DATA (XPROCESS(proc)->name)); | 1544 XSTRING_DATA (XPROCESS(proc)->name)); |
1530 if (!PROCESS_LIVE_P (proc)) | 1545 CHECK_LIVE_PROCESS (proc); |
1531 error ("Process %s is not active", | |
1532 XSTRING_DATA (XPROCESS(proc)->name)); | |
1533 | 1546 |
1534 MAYBE_PROCMETH (kill_child_process, (proc, signo, current_group, nomsg)); | 1547 MAYBE_PROCMETH (kill_child_process, (proc, signo, current_group, nomsg)); |
1535 } | 1548 } |
1536 | 1549 |
1537 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /* | 1550 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /* |
1817 /************************************************************************/ | 1830 /************************************************************************/ |
1818 | 1831 |
1819 void | 1832 void |
1820 deactivate_process (Lisp_Object proc) | 1833 deactivate_process (Lisp_Object proc) |
1821 { | 1834 { |
1822 struct Lisp_Process *p = XPROCESS (proc); | 1835 Lisp_Process *p = XPROCESS (proc); |
1823 USID usid; | 1836 USID usid; |
1824 | 1837 |
1825 /* It's possible that we got as far in the process-creation | 1838 /* It's possible that we got as far in the process-creation |
1826 process as creating the descriptors but didn't get so | 1839 process as creating the descriptors but didn't get so |
1827 far as selecting the process for input. In this | 1840 far as selecting the process for input. In this |
1870 PROCESS may be a process or the name of one, or a buffer name. | 1883 PROCESS may be a process or the name of one, or a buffer name. |
1871 */ | 1884 */ |
1872 (proc)) | 1885 (proc)) |
1873 { | 1886 { |
1874 /* This function can GC */ | 1887 /* This function can GC */ |
1875 struct Lisp_Process *p; | 1888 Lisp_Process *p; |
1876 proc = get_process (proc); | 1889 proc = get_process (proc); |
1877 p = XPROCESS (proc); | 1890 p = XPROCESS (proc); |
1878 if (network_connection_p (proc)) | 1891 if (network_connection_p (proc)) |
1879 { | 1892 { |
1880 p->status_symbol = Qexit; | 1893 p->status_symbol = Qexit; |
1881 p->exit_code = 0; | 1894 p->exit_code = 0; |
1882 p->core_dumped = 0; | 1895 p->core_dumped = 0; |
1883 p->tick++; | 1896 p->tick++; |
1884 process_tick++; | 1897 process_tick++; |
1885 } | 1898 } |
1886 else if (!NILP(p->pipe_instream)) | 1899 else if (PROCESS_LIVE_P (p)) |
1887 { | 1900 { |
1888 Fkill_process (proc, Qnil); | 1901 Fkill_process (proc, Qnil); |
1889 /* Do this now, since remove_process will make sigchld_handler do nothing. */ | 1902 /* Do this now, since remove_process will make sigchld_handler do nothing. */ |
1890 p->status_symbol = Qsignal; | 1903 p->status_symbol = Qsignal; |
1891 p->exit_code = SIGKILL; | 1904 p->exit_code = SIGKILL; |
1913 if (PROCESSP (proc) | 1926 if (PROCESSP (proc) |
1914 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) | 1927 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) |
1915 { | 1928 { |
1916 if (network_connection_p (proc)) | 1929 if (network_connection_p (proc)) |
1917 Fdelete_process (proc); | 1930 Fdelete_process (proc); |
1918 else if (!NILP (XPROCESS (proc)->pipe_instream)) | 1931 else if (PROCESS_LIVE_P (XPROCESS (proc))) |
1919 process_send_signal (proc, SIGHUP, 0, 1); | 1932 process_send_signal (proc, SIGHUP, 0, 1); |
1920 } | 1933 } |
1921 } | 1934 } |
1922 } | 1935 } |
1923 | 1936 |
1976 | 1989 |
1977 void | 1990 void |
1978 syms_of_process (void) | 1991 syms_of_process (void) |
1979 { | 1992 { |
1980 defsymbol (&Qprocessp, "processp"); | 1993 defsymbol (&Qprocessp, "processp"); |
1994 defsymbol (&Qprocess_live_p, "process-live-p"); | |
1981 defsymbol (&Qrun, "run"); | 1995 defsymbol (&Qrun, "run"); |
1982 defsymbol (&Qstop, "stop"); | 1996 defsymbol (&Qstop, "stop"); |
1983 defsymbol (&Qopen, "open"); | 1997 defsymbol (&Qopen, "open"); |
1984 defsymbol (&Qclosed, "closed"); | 1998 defsymbol (&Qclosed, "closed"); |
1985 | 1999 |
1989 #ifdef HAVE_MULTICAST | 2003 #ifdef HAVE_MULTICAST |
1990 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */ | 2004 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */ |
1991 #endif | 2005 #endif |
1992 | 2006 |
1993 DEFSUBR (Fprocessp); | 2007 DEFSUBR (Fprocessp); |
2008 DEFSUBR (Fprocess_live_p); | |
1994 DEFSUBR (Fget_process); | 2009 DEFSUBR (Fget_process); |
1995 DEFSUBR (Fget_buffer_process); | 2010 DEFSUBR (Fget_buffer_process); |
1996 DEFSUBR (Fdelete_process); | 2011 DEFSUBR (Fdelete_process); |
1997 DEFSUBR (Fprocess_status); | 2012 DEFSUBR (Fprocess_status); |
1998 DEFSUBR (Fprocess_exit_status); | 2013 DEFSUBR (Fprocess_exit_status); |