Mercurial > hg > xemacs-beta
comparison src/process.c @ 48:56c54cf7c5b6 r19-16b90
Import from CVS: tag r19-16b90
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:56:04 +0200 |
parents | 8d2a9b52c682 |
children | 131b0175ea99 |
comparison
equal
deleted
inserted
replaced
47:11c6df210d7f | 48:56c54cf7c5b6 |
---|---|
1021 close_descriptor_pair (forkin, forkout); | 1021 close_descriptor_pair (forkin, forkout); |
1022 report_file_error ("Doing vfork", Qnil); | 1022 report_file_error ("Doing vfork", Qnil); |
1023 } | 1023 } |
1024 | 1024 |
1025 p->pid = make_int (pid); | 1025 p->pid = make_int (pid); |
1026 /* #### dmoore - why is this commented out, otherwise we leave | |
1027 subtty = forkin, but then we close forkin just below. */ | |
1026 /* p->subtty = -1; */ | 1028 /* p->subtty = -1; */ |
1027 | 1029 |
1028 #ifdef WINDOWSNT | 1030 #ifdef WINDOWSNT |
1029 register_child (pid, inchannel); | 1031 register_child (pid, inchannel); |
1030 #endif /* WINDOWSNT */ | 1032 #endif /* WINDOWSNT */ |
1092 INCODE and OUTCODE specify the coding-system objects used in input/output | 1094 INCODE and OUTCODE specify the coding-system objects used in input/output |
1093 from/to the process. | 1095 from/to the process. |
1094 */ | 1096 */ |
1095 (int nargs, Lisp_Object *args)) | 1097 (int nargs, Lisp_Object *args)) |
1096 { | 1098 { |
1099 /* This function can call lisp */ | |
1097 /* !!#### This function has not been Mule-ized */ | 1100 /* !!#### This function has not been Mule-ized */ |
1098 /* This function can GC */ | |
1099 Lisp_Object buffer, name, program, proc, current_dir; | 1101 Lisp_Object buffer, name, program, proc, current_dir; |
1100 Lisp_Object tem; | 1102 Lisp_Object tem; |
1101 int speccount = specpdl_depth (); | 1103 int speccount = specpdl_depth (); |
1104 struct gcpro gcpro1, gcpro2, gcpro3; | |
1102 #ifdef VMS | 1105 #ifdef VMS |
1103 char *new_argv; | 1106 char *new_argv; |
1104 int len; | 1107 int len; |
1105 #else | 1108 #else |
1106 char **new_argv; | 1109 char **new_argv; |
1107 #endif | 1110 #endif |
1108 int i; | 1111 int i; |
1109 | 1112 |
1113 name = args[0]; | |
1110 buffer = args[1]; | 1114 buffer = args[1]; |
1115 program = args[2]; | |
1116 current_dir = Qnil; | |
1117 | |
1118 /* Protect against various file handlers doing GCs below. */ | |
1119 GCPRO3 (buffer, program, current_dir); | |
1120 | |
1111 if (!NILP (buffer)) | 1121 if (!NILP (buffer)) |
1112 buffer = Fget_buffer_create (buffer); | 1122 buffer = Fget_buffer_create (buffer); |
1113 | 1123 |
1114 CHECK_STRING (args[0]); /* name */ | 1124 CHECK_STRING (name); |
1115 CHECK_STRING (args[2]); /* program */ | 1125 CHECK_STRING (program); |
1116 | 1126 |
1117 /* Make sure that the child will be able to chdir to the current | 1127 /* Make sure that the child will be able to chdir to the current |
1118 buffer's current directory, or its unhandled equivalent. We | 1128 buffer's current directory, or its unhandled equivalent. We |
1119 can't just have the child check for an error when it does the | 1129 can't just have the child check for an error when it does the |
1120 chdir, since it's in a vfork. | 1130 chdir, since it's in a vfork. |
1121 | 1131 |
1122 We have to GCPRO around this because Fexpand_file_name and | 1132 Note: these assignments and calls are like this in order to insure |
1123 Funhandled_file_name_directory might call a file name handling | 1133 "caller protects args" GC semantics. */ |
1124 function. The argument list is protected by the caller, so all | 1134 current_dir = current_buffer->directory; |
1125 we really have to worry about is buffer. */ | 1135 current_dir = Funhandled_file_name_directory (current_dir); |
1126 { | 1136 current_dir = expand_and_dir_to_file (current_dir, Qnil); |
1127 struct gcpro gcpro1, gcpro2; /* Caller gc-protects args[] */ | 1137 |
1128 | |
1129 current_dir = current_buffer->directory; | |
1130 | |
1131 GCPRO2 (buffer, current_dir); | |
1132 | |
1133 current_dir = | |
1134 expand_and_dir_to_file (Funhandled_file_name_directory (current_dir), | |
1135 Qnil); | |
1136 #if 0 /* This loser breaks ange-ftp */ | 1138 #if 0 /* This loser breaks ange-ftp */ |
1137 if (NILP (Ffile_accessible_directory_p (current_dir))) | 1139 /* dmoore - if you re-enable this code, you have to gcprotect |
1138 report_file_error ("Setting current directory", | 1140 current_buffer through the above calls. */ |
1139 list1 (current_buffer->directory)); | 1141 if (NILP (Ffile_accessible_directory_p (current_dir))) |
1142 report_file_error ("Setting current directory", | |
1143 list1 (current_buffer->directory)); | |
1140 #endif /* 0 */ | 1144 #endif /* 0 */ |
1141 | |
1142 UNGCPRO; | |
1143 } | |
1144 | |
1145 name = args[0]; | |
1146 program = args[2]; | |
1147 | 1145 |
1148 #ifdef VMS | 1146 #ifdef VMS |
1149 /* Make a one member argv with all args concatenated | 1147 /* Make a one member argv with all args concatenated |
1150 together separated by a blank. */ | 1148 together separated by a blank. */ |
1151 len = XSTRING_LENGTH (program) + 2; | 1149 len = XSTRING_LENGTH (program) + 2; |
1165 strcat (new_argv, XSTRING_DATA (tem)); | 1163 strcat (new_argv, XSTRING_DATA (tem)); |
1166 } | 1164 } |
1167 /* Need to add code here to check for program existence on VMS */ | 1165 /* Need to add code here to check for program existence on VMS */ |
1168 | 1166 |
1169 #else /* not VMS */ | 1167 #else /* not VMS */ |
1170 new_argv = (char **) | |
1171 alloca ((nargs - 1) * sizeof (char *)); | |
1172 | |
1173 new_argv[0] = (char *) XSTRING_DATA (program); | |
1174 | |
1175 /* If program file name is not absolute, search our path for it */ | 1168 /* If program file name is not absolute, search our path for it */ |
1176 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0)) | 1169 if (!IS_DIRECTORY_SEP (XSTRING_BYTE (program, 0)) |
1177 && !(XSTRING_LENGTH (program) > 1 | 1170 && !(XSTRING_LENGTH (program) > 1 |
1178 && IS_DEVICE_SEP (XSTRING_BYTE (program, 1)))) | 1171 && IS_DEVICE_SEP (XSTRING_BYTE (program, 1)))) |
1179 { | 1172 { |
1180 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; /* Caller protects args[] */ | 1173 struct gcpro ngcpro1; |
1181 GCPRO4 (buffer, current_dir, name, program); | 1174 |
1182 | |
1183 tem = Qnil; | 1175 tem = Qnil; |
1176 NGCPRO1 (tem); | |
1184 locate_file (Vexec_path, program, EXEC_SUFFIXES, &tem, | 1177 locate_file (Vexec_path, program, EXEC_SUFFIXES, &tem, |
1185 X_OK); | 1178 X_OK); |
1186 UNGCPRO; | |
1187 if (NILP (tem)) | 1179 if (NILP (tem)) |
1188 report_file_error ("Searching for program", list1 (program)); | 1180 report_file_error ("Searching for program", list1 (program)); |
1189 tem = Fexpand_file_name (tem, Qnil); | 1181 program = Fexpand_file_name (tem, Qnil); |
1190 new_argv[0] = (char *) XSTRING_DATA (tem); | 1182 NUNGCPRO; |
1191 } | 1183 } |
1192 else | 1184 else |
1193 { | 1185 { |
1194 /* #### dmoore - file-directory-p can call lisp, make sure everything | |
1195 here protects itself. */ | |
1196 if (!NILP (Ffile_directory_p (program))) | 1186 if (!NILP (Ffile_directory_p (program))) |
1197 error ("Specified program for new process is a directory"); | 1187 error ("Specified program for new process is a directory"); |
1198 } | 1188 } |
1199 | 1189 |
1190 /* Nothing below here GCs so our string pointers shouldn't move. */ | |
1191 new_argv = (char **) alloca ((nargs - 1) * sizeof (char *)); | |
1192 new_argv[0] = (char *) XSTRING_DATA (program); | |
1200 for (i = 3; i < nargs; i++) | 1193 for (i = 3; i < nargs; i++) |
1201 { | 1194 { |
1202 tem = args[i]; | 1195 tem = args[i]; |
1203 CHECK_STRING (tem); | 1196 CHECK_STRING (tem); |
1204 new_argv[i - 2] = (char *) XSTRING_DATA (tem); | 1197 new_argv[i - 2] = (char *) XSTRING_DATA (tem); |
1224 itself; it's all taken care of here. */ | 1217 itself; it's all taken care of here. */ |
1225 record_unwind_protect (start_process_unwind, proc); | 1218 record_unwind_protect (start_process_unwind, proc); |
1226 | 1219 |
1227 create_process (proc, new_argv, (char *) XSTRING_DATA (current_dir)); | 1220 create_process (proc, new_argv, (char *) XSTRING_DATA (current_dir)); |
1228 | 1221 |
1222 UNGCPRO; | |
1229 return unbind_to (speccount, proc); | 1223 return unbind_to (speccount, proc); |
1230 } | 1224 } |
1231 | 1225 |
1232 | 1226 |
1233 /* connect to an existing file descriptor. This is very similar to | 1227 /* connect to an existing file descriptor. This is very similar to |
1726 | 1720 |
1727 MARK_MODELINE_CHANGED; | 1721 MARK_MODELINE_CHANGED; |
1728 | 1722 |
1729 /* If the restriction isn't what it should be, set it. */ | 1723 /* If the restriction isn't what it should be, set it. */ |
1730 if (old_begv != BUF_BEGV (buf) || old_zv != BUF_ZV (buf)) | 1724 if (old_begv != BUF_BEGV (buf) || old_zv != BUF_ZV (buf)) |
1731 Fnarrow_to_region (make_int (old_begv), make_int (old_zv), | 1725 { |
1732 p->buffer); | 1726 Fwiden(p->buffer); |
1727 old_begv = bufpos_clip_to_bounds (BUF_BEG (buf), | |
1728 old_begv, | |
1729 BUF_Z (buf)); | |
1730 old_zv = bufpos_clip_to_bounds (BUF_BEG (buf), | |
1731 old_zv, | |
1732 BUF_Z (buf)); | |
1733 Fnarrow_to_region (make_int (old_begv), make_int (old_zv), | |
1734 p->buffer); | |
1735 } | |
1733 | 1736 |
1734 /* Handling the process output should not deactivate the mark. */ | 1737 /* Handling the process output should not deactivate the mark. */ |
1735 zmacs_region_stays = old_zmacs_region_stays; | 1738 zmacs_region_stays = old_zmacs_region_stays; |
1736 buf->read_only = old_read_only; | 1739 buf->read_only = old_read_only; |
1740 old_point = bufpos_clip_to_bounds (BUF_BEGV (buf), | |
1741 old_point, | |
1742 BUF_ZV (buf)); | |
1737 BUF_SET_PT (buf, old_point); | 1743 BUF_SET_PT (buf, old_point); |
1738 | 1744 |
1739 UNGCPRO; | 1745 UNGCPRO; |
1740 } | 1746 } |
1741 #ifdef VMS | 1747 #ifdef VMS |
2506 Finsert (1, &msg); | 2512 Finsert (1, &msg); |
2507 current_buffer->read_only = old_read_only; | 2513 current_buffer->read_only = old_read_only; |
2508 Fset_marker (p->mark, make_int (BUF_PT (current_buffer)), | 2514 Fset_marker (p->mark, make_int (BUF_PT (current_buffer)), |
2509 p->buffer); | 2515 p->buffer); |
2510 | 2516 |
2517 opoint = bufpos_clip_to_bounds(BUF_BEGV (XBUFFER (p->buffer)), | |
2518 opoint, | |
2519 BUF_ZV (XBUFFER (p->buffer))); | |
2511 BUF_SET_PT (current_buffer, opoint); | 2520 BUF_SET_PT (current_buffer, opoint); |
2512 Fset_buffer (old); | 2521 Fset_buffer (old); |
2513 NUNGCPRO; | 2522 NUNGCPRO; |
2514 } | 2523 } |
2515 } | 2524 } |