Mercurial > hg > xemacs-beta
comparison src/process.c @ 120:cca96a509cfe r20-1b12
Import from CVS: tag r20-1b12
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:25:29 +0200 |
parents | 9f59509498e1 |
children | b980b6286996 |
comparison
equal
deleted
inserted
replaced
119:d101af7320b8 | 120:cca96a509cfe |
---|---|
779 pty_max_bytes, eof_char); | 779 pty_max_bytes, eof_char); |
780 } | 780 } |
781 #ifdef MULE | 781 #ifdef MULE |
782 p->instream = make_decoding_input_stream | 782 p->instream = make_decoding_input_stream |
783 (XLSTREAM (p->instream), | 783 (XLSTREAM (p->instream), |
784 Fget_coding_system (Vprocess_input_coding_system)); | 784 Fget_coding_system (Vcoding_system_for_read)); |
785 Lstream_set_character_mode (XLSTREAM (p->instream)); | 785 Lstream_set_character_mode (XLSTREAM (p->instream)); |
786 p->outstream = make_encoding_output_stream | 786 p->outstream = make_encoding_output_stream |
787 (XLSTREAM (p->outstream), | 787 (XLSTREAM (p->outstream), |
788 Fget_coding_system (Vprocess_output_coding_system)); | 788 Fget_coding_system (Vcoding_system_for_write)); |
789 /* CODE_CNTL (&out_state[outchannel]) |= CC_END; !!#### | 789 /* CODE_CNTL (&out_state[outchannel]) |= CC_END; !!#### |
790 What's going on here? */ | 790 What's going on here? */ |
791 #endif /* MULE */ | 791 #endif /* MULE */ |
792 } | 792 } |
793 | 793 |
1025 close_descriptor_pair (forkin, forkout); | 1025 close_descriptor_pair (forkin, forkout); |
1026 report_file_error ("Doing vfork", Qnil); | 1026 report_file_error ("Doing vfork", Qnil); |
1027 } | 1027 } |
1028 | 1028 |
1029 p->pid = make_int (pid); | 1029 p->pid = make_int (pid); |
1030 /* #### dmoore - why is this commented out, otherwise we leave | |
1031 subtty = forkin, but then we close forkin just below. */ | |
1030 /* p->subtty = -1; */ | 1032 /* p->subtty = -1; */ |
1031 | 1033 |
1032 #ifdef WINDOWSNT | 1034 #ifdef WINDOWSNT |
1033 register_child (pid, inchannel); | 1035 register_child (pid, inchannel); |
1034 #endif /* WINDOWSNT */ | 1036 #endif /* WINDOWSNT */ |
1096 INCODE and OUTCODE specify the coding-system objects used in input/output | 1098 INCODE and OUTCODE specify the coding-system objects used in input/output |
1097 from/to the process. | 1099 from/to the process. |
1098 */ | 1100 */ |
1099 (int nargs, Lisp_Object *args)) | 1101 (int nargs, Lisp_Object *args)) |
1100 { | 1102 { |
1103 /* This function can call lisp */ | |
1101 /* !!#### This function has not been Mule-ized */ | 1104 /* !!#### This function has not been Mule-ized */ |
1102 /* This function can GC */ | |
1103 Lisp_Object buffer, name, program, proc, current_dir; | 1105 Lisp_Object buffer, name, program, proc, current_dir; |
1104 Lisp_Object tem; | 1106 Lisp_Object tem; |
1105 int speccount = specpdl_depth (); | 1107 int speccount = specpdl_depth (); |
1108 struct gcpro gcpro1, gcpro2, gcpro3; | |
1106 #ifdef VMS | 1109 #ifdef VMS |
1107 char *new_argv; | 1110 char *new_argv; |
1108 int len; | 1111 int len; |
1109 #else | 1112 #else |
1110 char **new_argv; | 1113 char **new_argv; |
1111 #endif | 1114 #endif |
1112 int i; | 1115 int i; |
1113 | 1116 |
1117 name = args[0]; | |
1114 buffer = args[1]; | 1118 buffer = args[1]; |
1119 program = args[2]; | |
1120 current_dir = Qnil; | |
1121 | |
1122 /* Protect against various file handlers doing GCs below. */ | |
1123 GCPRO3 (buffer, program, current_dir); | |
1124 | |
1115 if (!NILP (buffer)) | 1125 if (!NILP (buffer)) |
1116 buffer = Fget_buffer_create (buffer); | 1126 buffer = Fget_buffer_create (buffer); |
1117 | 1127 |
1118 CHECK_STRING (args[0]); /* name */ | 1128 CHECK_STRING (name); |
1119 CHECK_STRING (args[2]); /* program */ | 1129 CHECK_STRING (program); |
1120 | 1130 |
1121 /* Make sure that the child will be able to chdir to the current | 1131 /* Make sure that the child will be able to chdir to the current |
1122 buffer's current directory, or its unhandled equivalent. We | 1132 buffer's current directory, or its unhandled equivalent. We |
1123 can't just have the child check for an error when it does the | 1133 can't just have the child check for an error when it does the |
1124 chdir, since it's in a vfork. | 1134 chdir, since it's in a vfork. |
1125 | 1135 |
1126 We have to GCPRO around this because Fexpand_file_name and | 1136 Note: these assignments and calls are like this in order to insure |
1127 Funhandled_file_name_directory might call a file name handling | 1137 "caller protects args" GC semantics. */ |
1128 function. The argument list is protected by the caller, so all | 1138 current_dir = current_buffer->directory; |
1129 we really have to worry about is buffer. */ | 1139 current_dir = Funhandled_file_name_directory (current_dir); |
1130 { | 1140 current_dir = expand_and_dir_to_file (current_dir, Qnil); |
1131 struct gcpro gcpro1, gcpro2; /* Caller gc-protects args[] */ | 1141 |
1132 | |
1133 current_dir = current_buffer->directory; | |
1134 | |
1135 GCPRO2 (buffer, current_dir); | |
1136 | |
1137 current_dir = | |
1138 expand_and_dir_to_file (Funhandled_file_name_directory (current_dir), | |
1139 Qnil); | |
1140 #if 0 /* This loser breaks ange-ftp */ | 1142 #if 0 /* This loser breaks ange-ftp */ |
1141 if (NILP (Ffile_accessible_directory_p (current_dir))) | 1143 /* dmoore - if you re-enable this code, you have to gcprotect |
1142 report_file_error ("Setting current directory", | 1144 current_buffer through the above calls. */ |
1143 list1 (current_buffer->directory)); | 1145 if (NILP (Ffile_accessible_directory_p (current_dir))) |
1146 report_file_error ("Setting current directory", | |
1147 list1 (current_buffer->directory)); | |
1144 #endif /* 0 */ | 1148 #endif /* 0 */ |
1145 | |
1146 UNGCPRO; | |
1147 } | |
1148 | |
1149 name = args[0]; | |
1150 program = args[2]; | |
1151 | 1149 |
1152 #ifdef VMS | 1150 #ifdef VMS |
1153 /* Make a one member argv with all args concatenated | 1151 /* Make a one member argv with all args concatenated |
1154 together separated by a blank. */ | 1152 together separated by a blank. */ |
1155 len = XSTRING_LENGTH (program) + 2; | 1153 len = XSTRING_LENGTH (program) + 2; |
1169 strcat (new_argv, XSTRING_DATA (tem)); | 1167 strcat (new_argv, XSTRING_DATA (tem)); |
1170 } | 1168 } |
1171 /* Need to add code here to check for program existence on VMS */ | 1169 /* Need to add code here to check for program existence on VMS */ |
1172 | 1170 |
1173 #else /* not VMS */ | 1171 #else /* not VMS */ |
1174 new_argv = (char **) | |
1175 alloca ((nargs - 1) * sizeof (char *)); | |
1176 | |
1177 new_argv[0] = (char *) XSTRING_DATA (program); | |
1178 | |
1179 /* If program file name is not absolute, search our path for it */ | 1172 /* If program file name is not absolute, search our path for it */ |
1180 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0)) | 1173 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0)) |
1181 && !(XSTRING_LENGTH (program) > 1 | 1174 && !(XSTRING_LENGTH (program) > 1 |
1182 && IS_DEVICE_SEP (XSTRING_BYTE (program, 1)))) | 1175 && IS_DEVICE_SEP (XSTRING_BYTE (program, 1)))) |
1183 { | 1176 { |
1184 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; /* Caller protects args[] */ | 1177 struct gcpro ngcpro1; |
1185 GCPRO4 (buffer, current_dir, name, program); | |
1186 | 1178 |
1187 tem = Qnil; | 1179 tem = Qnil; |
1180 NGCPRO1 (tem); | |
1188 locate_file (Vexec_path, program, EXEC_SUFFIXES, &tem, | 1181 locate_file (Vexec_path, program, EXEC_SUFFIXES, &tem, |
1189 X_OK); | 1182 X_OK); |
1190 UNGCPRO; | |
1191 if (NILP (tem)) | 1183 if (NILP (tem)) |
1192 report_file_error ("Searching for program", list1 (program)); | 1184 report_file_error ("Searching for program", list1 (program)); |
1193 tem = Fexpand_file_name (tem, Qnil); | 1185 program = Fexpand_file_name (tem, Qnil); |
1194 new_argv[0] = (char *) XSTRING_DATA (tem); | 1186 NUNGCPRO; |
1195 } | 1187 } |
1196 else | 1188 else |
1197 { | 1189 { |
1198 /* #### dmoore - file-directory-p can call lisp, make sure everything | |
1199 here protects itself. */ | |
1200 if (!NILP (Ffile_directory_p (program))) | 1190 if (!NILP (Ffile_directory_p (program))) |
1201 error ("Specified program for new process is a directory"); | 1191 error ("Specified program for new process is a directory"); |
1202 } | 1192 } |
1203 | 1193 |
1194 /* Nothing below here GCs so our string pointers shouldn't move. */ | |
1195 new_argv = (char **) alloca ((nargs - 1) * sizeof (char *)); | |
1196 new_argv[0] = (char *) XSTRING_DATA (program); | |
1204 for (i = 3; i < nargs; i++) | 1197 for (i = 3; i < nargs; i++) |
1205 { | 1198 { |
1206 tem = args[i]; | 1199 tem = args[i]; |
1207 CHECK_STRING (tem); | 1200 CHECK_STRING (tem); |
1208 new_argv[i - 2] = (char *) XSTRING_DATA (tem); | 1201 new_argv[i - 2] = (char *) XSTRING_DATA (tem); |
1228 itself; it's all taken care of here. */ | 1221 itself; it's all taken care of here. */ |
1229 record_unwind_protect (start_process_unwind, proc); | 1222 record_unwind_protect (start_process_unwind, proc); |
1230 | 1223 |
1231 create_process (proc, new_argv, (char *) XSTRING_DATA (current_dir)); | 1224 create_process (proc, new_argv, (char *) XSTRING_DATA (current_dir)); |
1232 | 1225 |
1226 UNGCPRO; | |
1233 return unbind_to (speccount, proc); | 1227 return unbind_to (speccount, proc); |
1234 } | 1228 } |
1235 | 1229 |
1236 | 1230 |
1237 /* connect to an existing file descriptor. This is very similar to | 1231 /* connect to an existing file descriptor. This is very similar to |
2026 { | 2020 { |
2027 process = get_process (process); | 2021 process = get_process (process); |
2028 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->outstream)); | 2022 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->outstream)); |
2029 } | 2023 } |
2030 | 2024 |
2025 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* | |
2026 Return a pair of coding-system for decoding and encoding of PROCESS. | |
2027 */ | |
2028 (process)) | |
2029 { | |
2030 process = get_process (process); | |
2031 return Fcons(decoding_stream_coding_system | |
2032 (XLSTREAM (XPROCESS (process)->instream)), | |
2033 encoding_stream_coding_system | |
2034 (XLSTREAM (XPROCESS (process)->outstream)) ); | |
2035 } | |
2036 | |
2031 DEFUN ("set-process-input-coding-system", | 2037 DEFUN ("set-process-input-coding-system", |
2032 Fset_process_input_coding_system, 2, 2, 0, /* | 2038 Fset_process_input_coding_system, 2, 2, 0, /* |
2033 Set PROCESS's input coding system to CODESYS. | 2039 Set PROCESS's input coding system to CODESYS. |
2034 */ | 2040 */ |
2035 (process, codesys)) | 2041 (process, codesys)) |
2048 { | 2054 { |
2049 codesys = Fget_coding_system (codesys); | 2055 codesys = Fget_coding_system (codesys); |
2050 process = get_process (process); | 2056 process = get_process (process); |
2051 set_encoding_stream_coding_system | 2057 set_encoding_stream_coding_system |
2052 ( XLSTREAM ( XPROCESS (process)->outstream), codesys); | 2058 ( XLSTREAM ( XPROCESS (process)->outstream), codesys); |
2059 return Qnil; | |
2060 } | |
2061 | |
2062 DEFUN ("set-process-coding-system", | |
2063 Fset_process_coding_system, 1, 3, 0, /* | |
2064 Set coding-systems of PROCESS to DECODING and ENCODING. | |
2065 */ | |
2066 (process, decoding, encoding)) | |
2067 { | |
2068 if(!NILP(decoding)){ | |
2069 Fset_process_input_coding_system(process, decoding); | |
2070 } | |
2071 if(!NILP(encoding)){ | |
2072 Fset_process_output_coding_system(process, encoding); | |
2073 } | |
2053 return Qnil; | 2074 return Qnil; |
2054 } | 2075 } |
2055 | 2076 |
2056 #endif /* MULE */ | 2077 #endif /* MULE */ |
2057 | 2078 |
3334 #ifdef MULE | 3355 #ifdef MULE |
3335 DEFSUBR (Fprocess_input_coding_system); | 3356 DEFSUBR (Fprocess_input_coding_system); |
3336 DEFSUBR (Fprocess_output_coding_system); | 3357 DEFSUBR (Fprocess_output_coding_system); |
3337 DEFSUBR (Fset_process_input_coding_system); | 3358 DEFSUBR (Fset_process_input_coding_system); |
3338 DEFSUBR (Fset_process_output_coding_system); | 3359 DEFSUBR (Fset_process_output_coding_system); |
3360 DEFSUBR (Fprocess_coding_system); | |
3361 DEFSUBR (Fset_process_coding_system); | |
3339 #endif /* MULE */ | 3362 #endif /* MULE */ |
3340 } | 3363 } |
3341 | 3364 |
3342 void | 3365 void |
3343 vars_of_process (void) | 3366 vars_of_process (void) |