aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorJim Blandy1992-12-12 15:36:50 +0000
committerJim Blandy1992-12-12 15:36:50 +0000
commit1e30af705a70316d1e8bb12b1f5364abf97296cb (patch)
treea9e40384c2547e7d8e094dea012b953833d25f29 /src/process.c
parente86f81cc46f817117847e8086d05092e08079d4c (diff)
downloademacs-1e30af705a70316d1e8bb12b1f5364abf97296cb.tar.gz
emacs-1e30af705a70316d1e8bb12b1f5364abf97296cb.zip
Give subprocess creation a way to find a valid current directory
for subprocesses when the buffer's default-directory is a handled name. * fileio.c (Funhandled_file_name_directory): New function. (Qunhandled_file_name_directory): New file-name-handler operation. (syms_of_fileio): Defsubr Sunhandled_file_name_directory, and initialize and staticpro Qunhandled_file_name_directory. * callproc.c (Fcall_process): Call Funhandled_file_name_directory on the buffer's default directory. Do it earlier in the function so there's less to GCPRO. * process.c (create_process): Don't check the validity of the buffer's default directory here... (Fstart_process): Instead, do it here; if we call Funhandled_file_name_directory here, there's less GCPROing to do.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c
index f343c594f05..1e1e2e339c2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -955,7 +955,7 @@ Remaining arguments are strings to give program as arguments.")
955 int nargs; 955 int nargs;
956 register Lisp_Object *args; 956 register Lisp_Object *args;
957{ 957{
958 Lisp_Object buffer, name, program, proc, tem; 958 Lisp_Object buffer, name, program, proc, current_dir, tem;
959#ifdef VMS 959#ifdef VMS
960 register unsigned char *new_argv; 960 register unsigned char *new_argv;
961 int len; 961 int len;
@@ -969,6 +969,32 @@ Remaining arguments are strings to give program as arguments.")
969 if (!NILP (buffer)) 969 if (!NILP (buffer))
970 buffer = Fget_buffer_create (buffer); 970 buffer = Fget_buffer_create (buffer);
971 971
972 /* Make sure that the child will be able to chdir to the current
973 buffer's current directory, or its unhandled equivalent. We
974 can't just have the child check for an error when it does the
975 chdir, since it's in a vfork.
976
977 We have to GCPRO around this because Fexpand_file_name and
978 Funhandled_file_name_directory might call a file name handling
979 function. The argument list is protected by the caller, so all
980 we really have to worry about is buffer. */
981 {
982 struct gcpro gcpro1, gcpro2;
983
984 current_dir = current_buffer->directory;
985
986 GCPRO2 (buffer, current_dir);
987
988 current_dir =
989 expand_and_dir_to_file
990 (Funhandled_file_name_directory (current_dir, Qnil));
991 if (NILP (Ffile_accessible_directory_p (current_dir)))
992 report_file_error ("Setting current directory",
993 Fcons (current_buffer->directory, Qnil));
994
995 UNGCPRO;
996 }
997
972 name = args[0]; 998 name = args[0];
973 CHECK_STRING (name, 0); 999 CHECK_STRING (name, 0);
974 1000
@@ -1034,7 +1060,7 @@ Remaining arguments are strings to give program as arguments.")
1034 XPROCESS (proc)->filter = Qnil; 1060 XPROCESS (proc)->filter = Qnil;
1035 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); 1061 XPROCESS (proc)->command = Flist (nargs - 2, args + 2);
1036 1062
1037 create_process (proc, new_argv); 1063 create_process (proc, new_argv, current_dir);
1038 1064
1039 return unbind_to (count, proc); 1065 return unbind_to (count, proc);
1040} 1066}
@@ -1089,9 +1115,10 @@ create_process_sigchld ()
1089#endif 1115#endif
1090 1116
1091#ifndef VMS /* VMS version of this function is in vmsproc.c. */ 1117#ifndef VMS /* VMS version of this function is in vmsproc.c. */
1092create_process (process, new_argv) 1118create_process (process, new_argv, current_dir)
1093 Lisp_Object process; 1119 Lisp_Object process;
1094 char **new_argv; 1120 char **new_argv;
1121 Lisp_Object current_dir;
1095{ 1122{
1096 int pid, inchannel, outchannel, forkin, forkout; 1123 int pid, inchannel, outchannel, forkin, forkout;
1097 int sv[2]; 1124 int sv[2];
@@ -1099,7 +1126,6 @@ create_process (process, new_argv)
1099 SIGTYPE (*sigchld)(); 1126 SIGTYPE (*sigchld)();
1100#endif 1127#endif
1101 int pty_flag = 0; 1128 int pty_flag = 0;
1102 Lisp_Object current_dir;
1103 extern char **environ; 1129 extern char **environ;
1104 1130
1105 inchannel = outchannel = -1; 1131 inchannel = outchannel = -1;
@@ -1108,14 +1134,6 @@ create_process (process, new_argv)
1108 if (EQ (Vprocess_connection_type, Qt)) 1134 if (EQ (Vprocess_connection_type, Qt))
1109 outchannel = inchannel = allocate_pty (); 1135 outchannel = inchannel = allocate_pty ();
1110 1136
1111 /* Make sure that the child will be able to chdir to the current
1112 buffer's current directory. We can't just have the child check
1113 for an error when it does the chdir, since it's in a vfork. */
1114 current_dir = expand_and_dir_to_file (current_buffer->directory, Qnil);
1115 if (NILP (Ffile_accessible_directory_p (current_dir)))
1116 report_file_error ("Setting current directory",
1117 Fcons (current_buffer->directory, Qnil));
1118
1119 if (inchannel >= 0) 1137 if (inchannel >= 0)
1120 { 1138 {
1121#ifndef USG 1139#ifndef USG