# HG changeset patch # User Jim Blandy # Date 724174610 0 # Node ID a0a41de51400523790df1afa4d030490bd176ec1 # Parent af0995b9b14269d22a6361a65f7c3b4963469775 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. diff -r af0995b9b142 -r a0a41de51400 src/process.c --- a/src/process.c Sat Dec 12 15:35:41 1992 +0000 +++ b/src/process.c Sat Dec 12 15:36:50 1992 +0000 @@ -955,7 +955,7 @@ int nargs; register Lisp_Object *args; { - Lisp_Object buffer, name, program, proc, tem; + Lisp_Object buffer, name, program, proc, current_dir, tem; #ifdef VMS register unsigned char *new_argv; int len; @@ -969,6 +969,32 @@ if (!NILP (buffer)) buffer = Fget_buffer_create (buffer); + /* Make sure that the child will be able to chdir to the current + buffer's current directory, or its unhandled equivalent. We + can't just have the child check for an error when it does the + chdir, since it's in a vfork. + + We have to GCPRO around this because Fexpand_file_name and + Funhandled_file_name_directory might call a file name handling + function. The argument list is protected by the caller, so all + we really have to worry about is buffer. */ + { + struct gcpro gcpro1, gcpro2; + + current_dir = current_buffer->directory; + + GCPRO2 (buffer, current_dir); + + current_dir = + expand_and_dir_to_file + (Funhandled_file_name_directory (current_dir, Qnil)); + if (NILP (Ffile_accessible_directory_p (current_dir))) + report_file_error ("Setting current directory", + Fcons (current_buffer->directory, Qnil)); + + UNGCPRO; + } + name = args[0]; CHECK_STRING (name, 0); @@ -1034,7 +1060,7 @@ XPROCESS (proc)->filter = Qnil; XPROCESS (proc)->command = Flist (nargs - 2, args + 2); - create_process (proc, new_argv); + create_process (proc, new_argv, current_dir); return unbind_to (count, proc); } @@ -1089,9 +1115,10 @@ #endif #ifndef VMS /* VMS version of this function is in vmsproc.c. */ -create_process (process, new_argv) +create_process (process, new_argv, current_dir) Lisp_Object process; char **new_argv; + Lisp_Object current_dir; { int pid, inchannel, outchannel, forkin, forkout; int sv[2]; @@ -1099,7 +1126,6 @@ SIGTYPE (*sigchld)(); #endif int pty_flag = 0; - Lisp_Object current_dir; extern char **environ; inchannel = outchannel = -1; @@ -1108,14 +1134,6 @@ if (EQ (Vprocess_connection_type, Qt)) outchannel = inchannel = allocate_pty (); - /* Make sure that the child will be able to chdir to the current - buffer's current directory. We can't just have the child check - for an error when it does the chdir, since it's in a vfork. */ - current_dir = expand_and_dir_to_file (current_buffer->directory, Qnil); - if (NILP (Ffile_accessible_directory_p (current_dir))) - report_file_error ("Setting current directory", - Fcons (current_buffer->directory, Qnil)); - if (inchannel >= 0) { #ifndef USG