# HG changeset patch # User Jim Blandy # Date 724174292 0 # Node ID 62ecf0c5b54cc8f66234b9f3ec26bb78bc9c6102 # Parent bf8ee433f4d2c03fe919bce32f64c7b1ea4608f8 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. * callproc.c (Fcall_process_region): Return the value returned by Fcall_process. diff -r bf8ee433f4d2 -r 62ecf0c5b54c src/callproc.c --- a/src/callproc.c Sat Dec 12 15:29:40 1992 +0000 +++ b/src/callproc.c Sat Dec 12 15:31:32 1992 +0000 @@ -126,7 +126,7 @@ int nargs; register Lisp_Object *args; { - Lisp_Object display, infile, buffer, path, current_dir; + Lisp_Object infile, buffer, current_dir, display, path; int fd[2]; int filefd; register int pid; @@ -168,6 +168,33 @@ else buffer = Qnil; + /* 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, + Funhandled_file_name_directory, and Ffile_accessible_directory_p + 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, gcpro3; + + current_dir = current_buffer->directory; + + GCPRO3 (infile, 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; + } + display = nargs >= 4 ? args[3] : Qnil; { @@ -207,14 +234,6 @@ #endif } - /* 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)); - { /* child_setup must clobber environ in systems with true vfork. Protect it from permanent change. */ @@ -359,9 +378,8 @@ Fdelete_region (start, end); args[3] = filename_string; - Fcall_process (nargs - 2, args + 2); - return unbind_to (count, Qnil); + return unbind_to (count, Fcall_process (nargs - 2, args + 2)); } #ifndef VMS /* VMS version is in vmsproc.c. */