Mercurial > hg > xemacs-beta
comparison src/process.c @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | fdefd0186b75 |
children | 11e10b9141d0 |
comparison
equal
deleted
inserted
replaced
770:336a418893b5 | 771:943eaba38521 |
---|---|
1 /* Asynchronous subprocess control for XEmacs. | 1 /* Asynchronous subprocess control for XEmacs. |
2 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995 | 2 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Copyright (C) 1995 Sun Microsystems, Inc. | 4 Copyright (C) 1995 Sun Microsystems, Inc. |
5 Copyright (C) 1995, 1996 Ben Wing. | 5 Copyright (C) 1995, 1996, 2001 Ben Wing. |
6 | 6 |
7 This file is part of XEmacs. | 7 This file is part of XEmacs. |
8 | 8 |
9 XEmacs is free software; you can redistribute it and/or modify it | 9 XEmacs is free software; you can redistribute it and/or modify it |
10 under the terms of the GNU General Public License as published by the | 10 under the terms of the GNU General Public License as published by the |
45 #include "lstream.h" | 45 #include "lstream.h" |
46 #include "opaque.h" | 46 #include "opaque.h" |
47 #include "process.h" | 47 #include "process.h" |
48 #include "procimpl.h" | 48 #include "procimpl.h" |
49 #include "window.h" | 49 #include "window.h" |
50 #ifdef FILE_CODING | |
51 #include "file-coding.h" | 50 #include "file-coding.h" |
52 #endif | |
53 | 51 |
54 #include "sysfile.h" | 52 #include "sysfile.h" |
55 #include "sysproc.h" | 53 #include "sysproc.h" |
56 #include "systime.h" | 54 #include "systime.h" |
57 #include "syssignal.h" /* Always include before systty.h */ | 55 #include "syssignal.h" /* Always include before systty.h */ |
107 Lisp_Object Vprocess_list; | 105 Lisp_Object Vprocess_list; |
108 | 106 |
109 extern Lisp_Object Vlisp_EXEC_SUFFIXES; | 107 extern Lisp_Object Vlisp_EXEC_SUFFIXES; |
110 Lisp_Object Vnull_device; | 108 Lisp_Object Vnull_device; |
111 | 109 |
110 /* Cons of coding systems used to initialize process I/O on a newly- | |
111 created process. */ | |
112 Lisp_Object Vdefault_process_coding_system; | |
113 | |
112 Lisp_Object Qprocess_error; | 114 Lisp_Object Qprocess_error; |
113 Lisp_Object Qnetwork_error; | 115 Lisp_Object Qnetwork_error; |
116 | |
117 Fixnum debug_process_io; | |
114 | 118 |
115 | 119 |
116 | 120 |
117 static Lisp_Object | 121 static Lisp_Object |
118 mark_process (Lisp_Object object) | 122 mark_process (Lisp_Object object) |
126 mark_object (process->buffer); | 130 mark_object (process->buffer); |
127 mark_object (process->mark); | 131 mark_object (process->mark); |
128 mark_object (process->pid); | 132 mark_object (process->pid); |
129 mark_object (process->pipe_instream); | 133 mark_object (process->pipe_instream); |
130 mark_object (process->pipe_outstream); | 134 mark_object (process->pipe_outstream); |
131 #ifdef FILE_CODING | |
132 mark_object (process->coding_instream); | 135 mark_object (process->coding_instream); |
133 mark_object (process->coding_outstream); | 136 mark_object (process->coding_outstream); |
134 #endif | |
135 return process->status_symbol; | 137 return process->status_symbol; |
136 } | 138 } |
137 | 139 |
138 static void | 140 static void |
139 print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag) | 141 print_process (Lisp_Object object, Lisp_Object printcharfun, int escapeflag) |
193 | 195 |
194 /************************************************************************/ | 196 /************************************************************************/ |
195 /* basic process accessors */ | 197 /* basic process accessors */ |
196 /************************************************************************/ | 198 /************************************************************************/ |
197 | 199 |
198 /* Under FILE_CODING, this function returns low-level streams, connected | 200 /* This function returns low-level streams, connected directly to the child |
199 directly to the child process, rather than en/decoding FILE_CODING | 201 process, rather than en/decoding streams */ |
200 streams */ | |
201 void | 202 void |
202 get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr) | 203 get_process_streams (Lisp_Process *p, Lisp_Object *instr, Lisp_Object *outstr) |
203 { | 204 { |
204 assert (p); | 205 assert (p); |
205 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream)); | 206 assert (NILP (p->pipe_instream) || LSTREAMP(p->pipe_instream)); |
363 | 364 |
364 invalid_argument ("Buffer has no process", buffer); | 365 invalid_argument ("Buffer has no process", buffer); |
365 } | 366 } |
366 else | 367 else |
367 return get_process (Fsignal (Qwrong_type_argument, | 368 return get_process (Fsignal (Qwrong_type_argument, |
368 (list2 (build_string ("process or buffer or nil"), | 369 (list2 (build_msg_string ("process or buffer or nil"), |
369 name)))); | 370 name)))); |
370 } | 371 } |
371 | 372 |
372 DEFUN ("process-id", Fprocess_id, 1, 1, 0, /* | 373 DEFUN ("process-id", Fprocess_id, 1, 1, 0, /* |
373 Return the process id of PROCESS. | 374 Return the process id of PROCESS. |
462 p->selected = 0; | 463 p->selected = 0; |
463 p->tick = 0; | 464 p->tick = 0; |
464 p->update_tick = 0; | 465 p->update_tick = 0; |
465 p->pipe_instream = Qnil; | 466 p->pipe_instream = Qnil; |
466 p->pipe_outstream = Qnil; | 467 p->pipe_outstream = Qnil; |
467 #ifdef FILE_CODING | |
468 p->coding_instream = Qnil; | 468 p->coding_instream = Qnil; |
469 p->coding_outstream = Qnil; | 469 p->coding_outstream = Qnil; |
470 #endif | |
471 | 470 |
472 p->process_data = 0; | 471 p->process_data = 0; |
473 MAYBE_PROCMETH (alloc_process_data, (p)); | 472 MAYBE_PROCMETH (alloc_process_data, (p)); |
474 | 473 |
475 XSETPROCESS (val, p); | 474 XSETPROCESS (val, p); |
479 } | 478 } |
480 | 479 |
481 void | 480 void |
482 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags) | 481 init_process_io_handles (Lisp_Process *p, void* in, void* out, int flags) |
483 { | 482 { |
484 USID usid = event_stream_create_stream_pair (in, out, | 483 USID usid; |
485 &p->pipe_instream, | 484 Lisp_Object incode, outcode; |
486 &p->pipe_outstream, | 485 |
487 flags); | 486 if (!CONSP (Vdefault_process_coding_system) || |
487 NILP (incode = (find_coding_system_for_text_file | |
488 (Fcar (Vdefault_process_coding_system), 1))) || | |
489 NILP (outcode = (find_coding_system_for_text_file | |
490 (Fcdr (Vdefault_process_coding_system), 0)))) | |
491 signal_error (Qinvalid_state, | |
492 "Bogus value for `default-process-coding-system'", | |
493 Vdefault_process_coding_system); | |
494 | |
495 usid = event_stream_create_stream_pair (in, out, | |
496 &p->pipe_instream, | |
497 &p->pipe_outstream, | |
498 flags); | |
488 | 499 |
489 if (usid == USID_ERROR) | 500 if (usid == USID_ERROR) |
490 signal_error (Qprocess_error, "Setting up communication with subprocess", | 501 signal_error (Qprocess_error, "Setting up communication with subprocess", |
491 Qunbound); | 502 Qunbound); |
492 | 503 |
493 if (usid != USID_DONTHASH) | 504 if (usid != USID_DONTHASH) |
494 { | 505 { |
495 Lisp_Object process = Qnil; | 506 Lisp_Object process = Qnil; |
496 XSETPROCESS (process, p); | 507 XSETPROCESS (process, p); |
497 puthash ((const void*)usid, LISP_TO_VOID (process), usid_to_process); | 508 puthash ((const void *) usid, LISP_TO_VOID (process), usid_to_process); |
498 } | 509 } |
499 | 510 |
500 MAYBE_PROCMETH (init_process_io_handles, (p, in, out, flags)); | 511 MAYBE_PROCMETH (init_process_io_handles, (p, in, out, flags)); |
501 | 512 |
502 #ifdef FILE_CODING | 513 p->coding_instream = |
503 p->coding_instream = make_decoding_input_stream | 514 make_coding_input_stream (XLSTREAM (p->pipe_instream), incode, CODING_DECODE); |
504 (XLSTREAM (p->pipe_instream), | |
505 Fget_coding_system (Vcoding_system_for_read)); | |
506 Lstream_set_character_mode (XLSTREAM (p->coding_instream)); | 515 Lstream_set_character_mode (XLSTREAM (p->coding_instream)); |
507 p->coding_outstream = make_encoding_output_stream | 516 p->coding_outstream = |
508 (XLSTREAM (p->pipe_outstream), | 517 make_coding_output_stream (XLSTREAM (p->pipe_outstream), outcode, CODING_ENCODE); |
509 Fget_coding_system (Vcoding_system_for_write)); | |
510 /* CODE_CNTL (&out_state[outchannel]) |= CC_END; !!#### | |
511 What's going on here? */ | |
512 #endif /* FILE_CODING */ | |
513 } | 518 } |
514 | 519 |
515 static void | 520 static void |
516 create_process (Lisp_Object process, Lisp_Object *argv, int nargv, | 521 create_process (Lisp_Object process, Lisp_Object *argv, int nargv, |
517 Lisp_Object program, Lisp_Object cur_dir) | 522 Lisp_Object program, Lisp_Object cur_dir) |
659 record_unwind_protect (start_process_unwind, process); | 664 record_unwind_protect (start_process_unwind, process); |
660 | 665 |
661 create_process (process, args + 3, nargs - 3, program, current_dir); | 666 create_process (process, args + 3, nargs - 3, program, current_dir); |
662 | 667 |
663 UNGCPRO; | 668 UNGCPRO; |
664 return unbind_to (speccount, process); | 669 return unbind_to_1 (speccount, process); |
665 } | 670 } |
666 | 671 |
667 | 672 |
668 #ifdef HAVE_SOCKETS | 673 #ifdef HAVE_SOCKETS |
669 | 674 |
720 are usually fine.) Note further that the UDP protocol does not guard | 725 are usually fine.) Note further that the UDP protocol does not guard |
721 against lost packets. | 726 against lost packets. |
722 */ | 727 */ |
723 (name, buffer, host, service, protocol)) | 728 (name, buffer, host, service, protocol)) |
724 { | 729 { |
725 /* !!#### This function has not been Mule-ized */ | |
726 /* This function can GC */ | 730 /* This function can GC */ |
727 Lisp_Object process = Qnil; | 731 Lisp_Object process = Qnil; |
728 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, ngcpro1; | 732 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, ngcpro1; |
729 void *inch, *outch; | 733 void *inch, *outch; |
730 | 734 |
731 GCPRO5 (name, buffer, host, service, protocol); | 735 GCPRO5 (name, buffer, host, service, protocol); |
732 CHECK_STRING (name); | 736 CHECK_STRING (name); |
733 | 737 |
734 if (NILP(protocol)) | 738 if (NILP (protocol)) |
735 protocol = Qtcp; | 739 protocol = Qtcp; |
736 else | 740 else |
737 CHECK_SYMBOL (protocol); | 741 CHECK_SYMBOL (protocol); |
738 | 742 |
739 /* Since this code is inside HAVE_SOCKETS, existence of | 743 /* Since this code is inside HAVE_SOCKETS, existence of |
746 process = make_process_internal (name); | 750 process = make_process_internal (name); |
747 NGCPRO1 (process); | 751 NGCPRO1 (process); |
748 | 752 |
749 XPROCESS (process)->pid = Fcons (service, host); | 753 XPROCESS (process)->pid = Fcons (service, host); |
750 XPROCESS (process)->buffer = buffer; | 754 XPROCESS (process)->buffer = buffer; |
751 init_process_io_handles (XPROCESS (process), (void*)inch, (void*)outch, | 755 init_process_io_handles (XPROCESS (process), (void *) inch, (void *) outch, |
752 STREAM_NETWORK_CONNECTION); | 756 STREAM_NETWORK_CONNECTION); |
753 | 757 |
754 event_stream_select_process (XPROCESS (process)); | 758 event_stream_select_process (XPROCESS (process)); |
755 | 759 |
756 UNGCPRO; | 760 UNGCPRO; |
776 port is a communication port like in traditional unicast | 780 port is a communication port like in traditional unicast |
777 ttl is the time-to-live (15 for site, 63 for region and 127 for world) | 781 ttl is the time-to-live (15 for site, 63 for region and 127 for world) |
778 */ | 782 */ |
779 (name, buffer, dest, port, ttl)) | 783 (name, buffer, dest, port, ttl)) |
780 { | 784 { |
781 /* !!#### This function has not been Mule-ized */ | |
782 /* This function can GC */ | 785 /* This function can GC */ |
783 Lisp_Object process = Qnil; | 786 Lisp_Object process = Qnil; |
784 struct gcpro gcpro1; | 787 struct gcpro gcpro1; |
785 void *inch, *outch; | 788 void *inch, *outch; |
786 | 789 |
787 CHECK_STRING (name); | 790 CHECK_STRING (name); |
788 | 791 |
789 /* Since this code is inside HAVE_MULTICAST, existence of | 792 /* Since this code is inside HAVE_MULTICAST, existence of |
790 open_network_stream is mandatory */ | 793 open_multicast_group is mandatory */ |
791 PROCMETH (open_multicast_group, (name, dest, port, ttl, | 794 PROCMETH (open_multicast_group, (name, dest, port, ttl, |
792 &inch, &outch)); | 795 &inch, &outch)); |
793 | 796 |
794 if (!NILP (buffer)) | 797 if (!NILP (buffer)) |
795 buffer = Fget_buffer_create (buffer); | 798 buffer = Fget_buffer_create (buffer); |
848 Charcount | 851 Charcount |
849 read_process_output (Lisp_Object process) | 852 read_process_output (Lisp_Object process) |
850 { | 853 { |
851 /* This function can GC */ | 854 /* This function can GC */ |
852 Bytecount nbytes, nchars; | 855 Bytecount nbytes, nchars; |
853 Intbyte chars[1024]; | 856 Intbyte chars[1025]; |
854 Lisp_Object outstream; | 857 Lisp_Object outstream; |
855 Lisp_Process *p = XPROCESS (process); | 858 Lisp_Process *p = XPROCESS (process); |
856 | 859 |
857 /* If there is a lot of output from the subprocess, the loop in | 860 /* If there is a lot of output from the subprocess, the loop in |
858 execute_internal_event() might call read_process_output() more | 861 execute_internal_event() might call read_process_output() more |
878 restore_match_data (); | 881 restore_match_data (); |
879 CHECK_INT (filter_result); | 882 CHECK_INT (filter_result); |
880 return XINT (filter_result); | 883 return XINT (filter_result); |
881 } | 884 } |
882 | 885 |
883 nbytes = Lstream_read (XLSTREAM (DATA_INSTREAM(p)), chars, sizeof (chars)); | 886 nbytes = Lstream_read (XLSTREAM (DATA_INSTREAM (p)), chars, |
887 sizeof (chars) - 1); | |
884 if (nbytes <= 0) return nbytes; | 888 if (nbytes <= 0) return nbytes; |
885 | 889 |
890 if (debug_process_io) | |
891 { | |
892 chars[nbytes] = '\0'; | |
893 stderr_out ("Read: %s\n", chars); | |
894 } | |
895 | |
896 /* !!#### if the coding system changed as a result of reading, we | |
897 need to change the output coding system accordingly. */ | |
886 nchars = bytecount_to_charcount (chars, nbytes); | 898 nchars = bytecount_to_charcount (chars, nbytes); |
887 outstream = p->filter; | 899 outstream = p->filter; |
888 if (!NILP (outstream)) | 900 if (!NILP (outstream)) |
889 { | 901 { |
890 /* We used to bind inhibit-quit to t here, but | 902 /* We used to bind inhibit-quit to t here, but |
1013 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable), | 1025 lstream = make_lisp_buffer_input_stream (XBUFFER (relocatable), |
1014 start, start + len, 0); | 1026 start, start + len, 0); |
1015 else | 1027 else |
1016 lstream = make_lisp_string_input_stream (relocatable, start, len); | 1028 lstream = make_lisp_string_input_stream (relocatable, start, len); |
1017 | 1029 |
1030 if (debug_process_io) | |
1031 { | |
1032 if (nonrelocatable) | |
1033 stderr_out ("Writing: %s\n", nonrelocatable); | |
1034 else | |
1035 { | |
1036 stderr_out ("Writing: "); | |
1037 print_internal (relocatable, Qexternal_debugging_output, 0); | |
1038 } | |
1039 } | |
1040 | |
1018 PROCMETH (send_process, (process, XLSTREAM (lstream))); | 1041 PROCMETH (send_process, (process, XLSTREAM (lstream))); |
1019 | 1042 |
1020 UNGCPRO; | 1043 UNGCPRO; |
1021 Lstream_delete (XLSTREAM (lstream)); | 1044 Lstream_delete (XLSTREAM (lstream)); |
1022 } | 1045 } |
1149 | 1172 |
1150 send_process (process, string, 0, bstart, bend - bstart); | 1173 send_process (process, string, 0, bstart, bend - bstart); |
1151 return Qnil; | 1174 return Qnil; |
1152 } | 1175 } |
1153 | 1176 |
1154 #ifdef FILE_CODING | |
1155 | 1177 |
1156 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /* | 1178 DEFUN ("process-input-coding-system", Fprocess_input_coding_system, 1, 1, 0, /* |
1157 Return PROCESS's input coding system. | 1179 Return PROCESS's input coding system. |
1158 */ | 1180 */ |
1159 (process)) | 1181 (process)) |
1160 { | 1182 { |
1161 process = get_process (process); | 1183 process = get_process (process); |
1162 CHECK_LIVE_PROCESS (process); | 1184 CHECK_LIVE_PROCESS (process); |
1163 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) ); | 1185 return (coding_stream_detected_coding_system |
1186 (XLSTREAM (XPROCESS (process)->coding_instream))); | |
1164 } | 1187 } |
1165 | 1188 |
1166 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* | 1189 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* |
1167 Return PROCESS's output coding system. | 1190 Return PROCESS's output coding system. |
1168 */ | 1191 */ |
1169 (process)) | 1192 (process)) |
1170 { | 1193 { |
1171 process = get_process (process); | 1194 process = get_process (process); |
1172 CHECK_LIVE_PROCESS (process); | 1195 CHECK_LIVE_PROCESS (process); |
1173 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream)); | 1196 return (coding_stream_coding_system |
1197 (XLSTREAM (XPROCESS (process)->coding_outstream))); | |
1174 } | 1198 } |
1175 | 1199 |
1176 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* | 1200 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* |
1177 Return a pair of coding-system for decoding and encoding of PROCESS. | 1201 Return a pair of coding-system for decoding and encoding of PROCESS. |
1178 */ | 1202 */ |
1179 (process)) | 1203 (process)) |
1180 { | 1204 { |
1181 process = get_process (process); | 1205 process = get_process (process); |
1182 CHECK_LIVE_PROCESS (process); | 1206 CHECK_LIVE_PROCESS (process); |
1183 return Fcons (decoding_stream_coding_system | 1207 return Fcons (coding_stream_detected_coding_system |
1184 (XLSTREAM (XPROCESS (process)->coding_instream)), | 1208 (XLSTREAM (XPROCESS (process)->coding_instream)), |
1185 encoding_stream_coding_system | 1209 coding_stream_coding_system |
1186 (XLSTREAM (XPROCESS (process)->coding_outstream))); | 1210 (XLSTREAM (XPROCESS (process)->coding_outstream))); |
1187 } | 1211 } |
1188 | 1212 |
1189 DEFUN ("set-process-input-coding-system", Fset_process_input_coding_system, | 1213 DEFUN ("set-process-input-coding-system", Fset_process_input_coding_system, |
1190 2, 2, 0, /* | 1214 2, 2, 0, /* |
1191 Set PROCESS's input coding system to CODESYS. | 1215 Set PROCESS's input coding system to CODESYS. |
1216 This is used for reading data from PROCESS. | |
1192 */ | 1217 */ |
1193 (process, codesys)) | 1218 (process, codesys)) |
1194 { | 1219 { |
1195 codesys = Fget_coding_system (codesys); | 1220 codesys = get_coding_system_for_text_file (codesys, 1); |
1196 process = get_process (process); | 1221 process = get_process (process); |
1197 CHECK_LIVE_PROCESS (process); | 1222 CHECK_LIVE_PROCESS (process); |
1198 | 1223 |
1199 set_decoding_stream_coding_system | 1224 set_coding_stream_coding_system |
1200 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); | 1225 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); |
1201 return Qnil; | 1226 return Qnil; |
1202 } | 1227 } |
1203 | 1228 |
1204 DEFUN ("set-process-output-coding-system", Fset_process_output_coding_system, | 1229 DEFUN ("set-process-output-coding-system", Fset_process_output_coding_system, |
1205 2, 2, 0, /* | 1230 2, 2, 0, /* |
1206 Set PROCESS's output coding system to CODESYS. | 1231 Set PROCESS's output coding system to CODESYS. |
1232 This is used for writing data to PROCESS. | |
1207 */ | 1233 */ |
1208 (process, codesys)) | 1234 (process, codesys)) |
1209 { | 1235 { |
1210 codesys = Fget_coding_system (codesys); | 1236 codesys = get_coding_system_for_text_file (codesys, 0); |
1211 process = get_process (process); | 1237 process = get_process (process); |
1212 CHECK_LIVE_PROCESS (process); | 1238 CHECK_LIVE_PROCESS (process); |
1213 | 1239 |
1214 set_encoding_stream_coding_system | 1240 set_coding_stream_coding_system |
1215 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); | 1241 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); |
1216 return Qnil; | 1242 return Qnil; |
1217 } | 1243 } |
1218 | 1244 |
1219 DEFUN ("set-process-coding-system", Fset_process_coding_system, | 1245 DEFUN ("set-process-coding-system", Fset_process_coding_system, |
1231 Fset_process_output_coding_system (process, encoding); | 1257 Fset_process_output_coding_system (process, encoding); |
1232 | 1258 |
1233 return Qnil; | 1259 return Qnil; |
1234 } | 1260 } |
1235 | 1261 |
1236 #endif /* FILE_CODING */ | |
1237 | 1262 |
1238 /************************************************************************/ | 1263 /************************************************************************/ |
1239 /* process status */ | 1264 /* process status */ |
1240 /************************************************************************/ | 1265 /************************************************************************/ |
1241 | 1266 |
1270 does that for us. */ | 1295 does that for us. */ |
1271 running_asynch_code = 1; | 1296 running_asynch_code = 1; |
1272 call2_trapping_errors ("Error in process sentinel", sentinel, process, reason); | 1297 call2_trapping_errors ("Error in process sentinel", sentinel, process, reason); |
1273 running_asynch_code = 0; | 1298 running_asynch_code = 0; |
1274 restore_match_data (); | 1299 restore_match_data (); |
1275 unbind_to (speccount, Qnil); | 1300 unbind_to (speccount); |
1276 } | 1301 } |
1277 | 1302 |
1278 DEFUN ("set-process-sentinel", Fset_process_sentinel, 2, 2, 0, /* | 1303 DEFUN ("set-process-sentinel", Fset_process_sentinel, 2, 2, 0, /* |
1279 Give PROCESS the sentinel SENTINEL; nil for none. | 1304 Give PROCESS the sentinel SENTINEL; nil for none. |
1280 The sentinel is called as a function when the process changes state. | 1305 The sentinel is called as a function when the process changes state. |
1332 | 1357 |
1333 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop)) | 1358 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop)) |
1334 { | 1359 { |
1335 string = build_string (signal_name (code)); | 1360 string = build_string (signal_name (code)); |
1336 if (coredump) | 1361 if (coredump) |
1337 string2 = build_translated_string (" (core dumped)\n"); | 1362 string2 = build_msg_string (" (core dumped)\n"); |
1338 else | 1363 else |
1339 string2 = build_string ("\n"); | 1364 string2 = build_string ("\n"); |
1340 set_string_char (XSTRING (string), 0, | 1365 set_string_char (XSTRING (string), 0, |
1341 DOWNCASE (current_buffer, | 1366 DOWNCASE (0, string_char (XSTRING (string), 0))); |
1342 string_char (XSTRING (string), 0))); | |
1343 return concat2 (string, string2); | 1367 return concat2 (string, string2); |
1344 } | 1368 } |
1345 else if (EQ (symbol, Qexit)) | 1369 else if (EQ (symbol, Qexit)) |
1346 { | 1370 { |
1347 if (code == 0) | 1371 if (code == 0) |
1348 return build_translated_string ("finished\n"); | 1372 return build_msg_string ("finished\n"); |
1349 string = Fnumber_to_string (make_int (code)); | 1373 string = Fnumber_to_string (make_int (code)); |
1350 if (coredump) | 1374 if (coredump) |
1351 string2 = build_translated_string (" (core dumped)\n"); | 1375 string2 = build_msg_string (" (core dumped)\n"); |
1352 else | 1376 else |
1353 string2 = build_string ("\n"); | 1377 string2 = build_string ("\n"); |
1354 return concat2 (build_translated_string ("exited abnormally with code "), | 1378 return concat2 (build_msg_string ("exited abnormally with code "), |
1355 concat2 (string, string2)); | 1379 concat2 (string, string2)); |
1356 } | 1380 } |
1357 else | 1381 else |
1358 return Fcopy_sequence (Fsymbol_name (symbol)); | 1382 return Fcopy_sequence (Fsymbol_name (symbol)); |
1359 } | 1383 } |
1873 if (!NILP (DATA_OUTSTREAM (XPROCESS (process)))) | 1897 if (!NILP (DATA_OUTSTREAM (XPROCESS (process)))) |
1874 { | 1898 { |
1875 Lstream_close (XLSTREAM (DATA_OUTSTREAM (XPROCESS (process)))); | 1899 Lstream_close (XLSTREAM (DATA_OUTSTREAM (XPROCESS (process)))); |
1876 event_stream_delete_stream_pair (Qnil, XPROCESS (process)->pipe_outstream); | 1900 event_stream_delete_stream_pair (Qnil, XPROCESS (process)->pipe_outstream); |
1877 XPROCESS (process)->pipe_outstream = Qnil; | 1901 XPROCESS (process)->pipe_outstream = Qnil; |
1878 #ifdef FILE_CODING | |
1879 XPROCESS (process)->coding_outstream = Qnil; | 1902 XPROCESS (process)->coding_outstream = Qnil; |
1880 #endif | |
1881 } | 1903 } |
1882 } | 1904 } |
1883 | 1905 |
1884 return process; | 1906 return process; |
1885 } | 1907 } |
1921 if (usid != USID_DONTHASH) | 1943 if (usid != USID_DONTHASH) |
1922 remhash ((const void*)usid, usid_to_process); | 1944 remhash ((const void*)usid, usid_to_process); |
1923 | 1945 |
1924 p->pipe_instream = Qnil; | 1946 p->pipe_instream = Qnil; |
1925 p->pipe_outstream = Qnil; | 1947 p->pipe_outstream = Qnil; |
1926 #ifdef FILE_CODING | |
1927 p->coding_instream = Qnil; | 1948 p->coding_instream = Qnil; |
1928 p->coding_outstream = Qnil; | 1949 p->coding_outstream = Qnil; |
1929 #endif | |
1930 } | 1950 } |
1931 | 1951 |
1932 static void | 1952 static void |
1933 remove_process (Lisp_Object process) | 1953 remove_process (Lisp_Object process) |
1934 { | 1954 { |
2100 DEFSUBR (Fstop_process); | 2120 DEFSUBR (Fstop_process); |
2101 DEFSUBR (Fcontinue_process); | 2121 DEFSUBR (Fcontinue_process); |
2102 DEFSUBR (Fprocess_send_eof); | 2122 DEFSUBR (Fprocess_send_eof); |
2103 DEFSUBR (Fsignal_process); | 2123 DEFSUBR (Fsignal_process); |
2104 /* DEFSUBR (Fprocess_connection); */ | 2124 /* DEFSUBR (Fprocess_connection); */ |
2105 #ifdef FILE_CODING | |
2106 DEFSUBR (Fprocess_input_coding_system); | 2125 DEFSUBR (Fprocess_input_coding_system); |
2107 DEFSUBR (Fprocess_output_coding_system); | 2126 DEFSUBR (Fprocess_output_coding_system); |
2108 DEFSUBR (Fset_process_input_coding_system); | 2127 DEFSUBR (Fset_process_input_coding_system); |
2109 DEFSUBR (Fset_process_output_coding_system); | 2128 DEFSUBR (Fset_process_output_coding_system); |
2110 DEFSUBR (Fprocess_coding_system); | 2129 DEFSUBR (Fprocess_coding_system); |
2111 DEFSUBR (Fset_process_coding_system); | 2130 DEFSUBR (Fset_process_coding_system); |
2112 #endif /* FILE_CODING */ | |
2113 } | 2131 } |
2114 | 2132 |
2115 void | 2133 void |
2116 vars_of_process (void) | 2134 vars_of_process (void) |
2117 { | 2135 { |
2174 Only Windows processes can be "windowed" or "console". This variable has no | 2192 Only Windows processes can be "windowed" or "console". This variable has no |
2175 effect on UNIX processes, because all UNIX processes are "console". | 2193 effect on UNIX processes, because all UNIX processes are "console". |
2176 */ ); | 2194 */ ); |
2177 windowed_process_io = 0; | 2195 windowed_process_io = 0; |
2178 | 2196 |
2197 DEFVAR_INT ("debug-process-io", &debug_process_io /* | |
2198 If non-zero, display data sent to or received from a process. | |
2199 */ ); | |
2200 debug_process_io = 0; | |
2201 | |
2202 DEFVAR_LISP ("default-process-coding-system", | |
2203 &Vdefault_process_coding_system /* | |
2204 Cons of coding systems used for process I/O by default. | |
2205 The car part is used for reading (decoding) data from a process, and | |
2206 the cdr part is used for writing (encoding) data to a process. | |
2207 */ ); | |
2208 /* This below will get its default set correctly in code-init.el. */ | |
2209 Vdefault_process_coding_system = Fcons (Qundecided, Qnil); | |
2210 | |
2179 #ifdef PROCESS_IO_BLOCKING | 2211 #ifdef PROCESS_IO_BLOCKING |
2180 DEFVAR_LISP ("network-stream-blocking-port-list", &network_stream_blocking_port_list /* | 2212 DEFVAR_LISP ("network-stream-blocking-port-list", &network_stream_blocking_port_list /* |
2181 List of port numbers or port names to set a blocking I/O mode with connection. | 2213 List of port numbers or port names to set a blocking I/O mode with connection. |
2182 Nil value means to set a default(non-blocking) I/O mode. | 2214 Nil value means to set a default(non-blocking) I/O mode. |
2183 The value takes effect when `open-network-stream-internal' is called. | 2215 The value takes effect when `open-network-stream-internal' is called. |