(read_minibuf_unwind): Clear last_overlay_modified field.
[bpt/emacs.git] / src / callproc.c
index 9151f0d..ffff3f4 100644 (file)
@@ -245,8 +245,16 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
       if (CONSP (buffer))
        {
          if (CONSP (XCONS (buffer)->cdr))
-           error_file = Fexpand_file_name (XCONS (XCONS (buffer)->cdr)->car,
-                                           Qnil);
+           {
+             Lisp_Object stderr_file;
+             stderr_file = XCONS (XCONS (buffer)->cdr)->car;
+
+             if (NILP (stderr_file) || EQ (Qt, stderr_file))
+               error_file = stderr_file;
+             else
+               error_file = Fexpand_file_name (stderr_file, Qnil);
+           }
+
          buffer = XCONS (buffer)->car;
        }
 
@@ -342,21 +350,19 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
   if (outfilefd < 0)
     {
       close (filefd);
-      report_file_error ("Opening process output file", Fcons (tempfile, Qnil));
+      report_file_error ("Opening process output file",
+                        Fcons (build_string (tempfile), Qnil));
     }
+  fd[0] = filefd;
   fd[1] = outfilefd;
-#endif
+#endif /* MSDOS */
 
   if (INTEGERP (buffer))
     fd[1] = open (NULL_DEVICE, O_WRONLY), fd[0] = -1;
   else
     {
 #ifndef MSDOS
-#ifdef WINDOWSNT
-      pipe_with_inherited_out (fd);
-#else  /* not WINDOWSNT */
       pipe (fd);
-#endif /* not WINDOWSNT */
 #endif
 #if 0
       /* Replaced by close_process_descs */
@@ -400,10 +406,17 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
     if (fd_error < 0)
       {
        close (filefd);
-       close (fd[0]);
+       if (fd[0] != filefd)
+         close (fd[0]);
        if (fd1 >= 0)
          close (fd1);
-       report_file_error ("Cannot open", error_file);
+#ifdef MSDOS
+       unlink (tempfile);
+#endif
+       report_file_error ("Cannot redirect stderr",
+                          Fcons ((NILP (error_file)
+                                  ? build_string (NULL_DEVICE) : error_file),
+                                 Qnil));
       }
 #ifdef MSDOS /* MW, July 1993 */
     /* ??? Someone who knows MSDOG needs to check whether this properly
@@ -443,7 +456,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
       {
        if (fd[0] >= 0)
          close (fd[0]);
-#ifdef USG
+#if defined(USG) && !defined(BSD_PGRPS)
         setpgrp ();
 #else
         setpgrp (pid, pid);
@@ -451,6 +464,10 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
        child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir);
       }
 #endif /* not WINDOWSNT */
+
+    /* The MSDOS case did this already.  */
+    if (fd_error >= 0)
+      close (fd_error);
 #endif /* not MSDOS */
 
     environ = save_environ;
@@ -458,7 +475,7 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
     /* Close most of our fd's, but not fd[0]
        since we will use that to read input from.  */
     close (filefd);
-    if (fd1 >= 0)
+    if (fd1 >= 0 && fd1 != fd_error)
       close (fd1);
   }
 
@@ -631,9 +648,12 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
       tempfile = alloca (20);
       *tempfile = '\0';
     }
-  dostounix_filename (tempfile);
   if (!IS_DIRECTORY_SEP (tempfile[strlen (tempfile) - 1]))
     strcat (tempfile, "/");
+  if ('/' == DIRECTORY_SEP)
+    dostounix_filename (tempfile);
+  else
+    unixtodos_filename (tempfile);
 #ifdef WINDOWSNT
   strcat (tempfile, "emXXXXXX");
 #else
@@ -708,7 +728,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
   char *pwd_var;
 #ifdef WINDOWSNT
   int cpid;
-  HANDLE handles[4];
+  HANDLE handles[3];
 #endif /* WINDOWSNT */
 
   int pid = getpid ();
@@ -848,7 +868,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
   close (err);
 #endif /* not WINDOWSNT */
 
-#ifdef USG
+#if defined(USG) && !defined(BSD_PGRPS)
 #ifndef SETPGRP_RELEASES_CTTY
   setpgrp ();                  /* No arguments but equivalent in this case */
 #endif
@@ -877,7 +897,7 @@ child_setup (in, out, err, new_argv, set_pgrp, current_dir)
   environ = env;
   execvp (new_argv[0], new_argv);
 
-  write (1, "Can't exec program: ", 26);
+  write (1, "Can't exec program: ", 20);
   write (1, new_argv[0], strlen (new_argv[0]));
   write (1, "\n", 1);
   _exit (1);