aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c81
1 files changed, 4 insertions, 77 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 4a320bf0b3d..a3b7b7afa4a 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -160,14 +160,14 @@ Lisp_Object
160call_process_cleanup (fdpid) 160call_process_cleanup (fdpid)
161 Lisp_Object fdpid; 161 Lisp_Object fdpid;
162{ 162{
163#if defined (MSDOS) || defined (MAC_OS8) 163#if defined (MSDOS)
164 /* for MSDOS fdpid is really (fd . tempfile) */ 164 /* for MSDOS fdpid is really (fd . tempfile) */
165 register Lisp_Object file; 165 register Lisp_Object file;
166 file = Fcdr (fdpid); 166 file = Fcdr (fdpid);
167 emacs_close (XFASTINT (Fcar (fdpid))); 167 emacs_close (XFASTINT (Fcar (fdpid)));
168 if (strcmp (SDATA (file), NULL_DEVICE) != 0) 168 if (strcmp (SDATA (file), NULL_DEVICE) != 0)
169 unlink (SDATA (file)); 169 unlink (SDATA (file));
170#else /* not MSDOS and not MAC_OS8 */ 170#else /* not MSDOS */
171 register int pid = XFASTINT (Fcdr (fdpid)); 171 register int pid = XFASTINT (Fcdr (fdpid));
172 172
173 if (call_process_exited) 173 if (call_process_exited)
@@ -244,10 +244,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
244 char *outf, *tempfile; 244 char *outf, *tempfile;
245 int outfilefd; 245 int outfilefd;
246#endif 246#endif
247#ifdef MAC_OS8
248 char *tempfile;
249 int outfilefd;
250#endif
251#if 0 247#if 0
252 int mask; 248 int mask;
253#endif 249#endif
@@ -471,32 +467,11 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
471 fd[1] = outfilefd; 467 fd[1] = outfilefd;
472#endif /* MSDOS */ 468#endif /* MSDOS */
473 469
474#ifdef MAC_OS8
475 /* Since we don't have pipes on the Mac, create a temporary file to
476 hold the output of the subprocess. */
477 tempfile = (char *) alloca (SBYTES (Vtemp_file_name_pattern) + 1);
478 bcopy (SDATA (Vtemp_file_name_pattern), tempfile,
479 SBYTES (Vtemp_file_name_pattern) + 1);
480
481 mktemp (tempfile);
482
483 outfilefd = creat (tempfile, S_IREAD | S_IWRITE);
484 if (outfilefd < 0)
485 {
486 close (filefd);
487 report_file_error ("Opening process output file",
488 Fcons (build_string (tempfile), Qnil));
489 }
490 fd[0] = filefd;
491 fd[1] = outfilefd;
492#endif /* MAC_OS8 */
493
494 if (INTEGERP (buffer)) 470 if (INTEGERP (buffer))
495 fd[1] = emacs_open (NULL_DEVICE, O_WRONLY, 0), fd[0] = -1; 471 fd[1] = emacs_open (NULL_DEVICE, O_WRONLY, 0), fd[0] = -1;
496 else 472 else
497 { 473 {
498#ifndef MSDOS 474#ifndef MSDOS
499#ifndef MAC_OS8
500 errno = 0; 475 errno = 0;
501 if (pipe (fd) == -1) 476 if (pipe (fd) == -1)
502 { 477 {
@@ -504,7 +479,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
504 report_file_error ("Creating process pipe", Qnil); 479 report_file_error ("Creating process pipe", Qnil);
505 } 480 }
506#endif 481#endif
507#endif
508#if 0 482#if 0
509 /* Replaced by close_process_descs */ 483 /* Replaced by close_process_descs */
510 set_exclusive_use (fd[0]); 484 set_exclusive_use (fd[0]);
@@ -562,52 +536,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
562 report_file_error ("Cannot redirect stderr", Fcons (error_file, Qnil)); 536 report_file_error ("Cannot redirect stderr", Fcons (error_file, Qnil));
563 } 537 }
564 538
565#ifdef MAC_OS8
566 {
567 /* Call run_mac_command in sysdep.c here directly instead of doing
568 a child_setup as for MSDOS and other platforms. Note that this
569 code does not handle passing the environment to the synchronous
570 Mac subprocess. */
571 char *infn, *outfn, *errfn, *currdn;
572
573 /* close these files so subprocess can write to them */
574 close (outfilefd);
575 if (fd_error != outfilefd)
576 close (fd_error);
577 fd1 = -1; /* No harm in closing that one! */
578
579 infn = SDATA (infile);
580 outfn = tempfile;
581 if (NILP (error_file))
582 errfn = NULL_DEVICE;
583 else if (EQ (Qt, error_file))
584 errfn = outfn;
585 else
586 errfn = SDATA (error_file);
587 currdn = SDATA (current_dir);
588 pid = run_mac_command (new_argv, currdn, infn, outfn, errfn);
589
590 /* Record that the synchronous process exited and note its
591 termination status. */
592 synch_process_alive = 0;
593 synch_process_retcode = pid;
594 if (synch_process_retcode < 0) /* means it couldn't be exec'ed */
595 {
596 synchronize_system_messages_locale ();
597 synch_process_death = strerror (errno);
598 }
599
600 /* Since CRLF is converted to LF within `decode_coding', we can
601 always open a file with binary mode. */
602 fd[0] = open (tempfile, O_BINARY);
603 if (fd[0] < 0)
604 {
605 unlink (tempfile);
606 close (filefd);
607 report_file_error ("Cannot re-open temporary file", Qnil);
608 }
609 }
610#else /* not MAC_OS8 */
611#ifdef MSDOS /* MW, July 1993 */ 539#ifdef MSDOS /* MW, July 1993 */
612 /* Note that on MSDOS `child_setup' actually returns the child process 540 /* Note that on MSDOS `child_setup' actually returns the child process
613 exit status, not its PID, so we assign it to `synch_process_retcode' 541 exit status, not its PID, so we assign it to `synch_process_retcode'
@@ -670,7 +598,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
670 if (fd_error >= 0) 598 if (fd_error >= 0)
671 emacs_close (fd_error); 599 emacs_close (fd_error);
672#endif /* not MSDOS */ 600#endif /* not MSDOS */
673#endif /* not MAC_OS8 */
674 601
675 environ = save_environ; 602 environ = save_environ;
676 603
@@ -704,14 +631,14 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
704 /* Enable sending signal if user quits below. */ 631 /* Enable sending signal if user quits below. */
705 call_process_exited = 0; 632 call_process_exited = 0;
706 633
707#if defined(MSDOS) || defined(MAC_OS8) 634#if defined(MSDOS)
708 /* MSDOS needs different cleanup information. */ 635 /* MSDOS needs different cleanup information. */
709 record_unwind_protect (call_process_cleanup, 636 record_unwind_protect (call_process_cleanup,
710 Fcons (make_number (fd[0]), build_string (tempfile))); 637 Fcons (make_number (fd[0]), build_string (tempfile)));
711#else 638#else
712 record_unwind_protect (call_process_cleanup, 639 record_unwind_protect (call_process_cleanup,
713 Fcons (make_number (fd[0]), make_number (pid))); 640 Fcons (make_number (fd[0]), make_number (pid)));
714#endif /* not MSDOS and not MAC_OS8 */ 641#endif /* not MSDOS */
715 642
716 643
717 if (BUFFERP (buffer)) 644 if (BUFFERP (buffer))