aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-12-05 10:29:52 -0800
committerPaul Eggert2012-12-05 10:29:52 -0800
commit644d3f0dbf38eca7a746e0fb5a7a0dd20d214949 (patch)
tree5a8626e0d9f34ef6cf54afea65de0446a339e5cb /src/callproc.c
parentffcee8d7c43cef38612c39554212a5a20b75e05b (diff)
downloademacs-644d3f0dbf38eca7a746e0fb5a7a0dd20d214949.tar.gz
emacs-644d3f0dbf38eca7a746e0fb5a7a0dd20d214949.zip
Minor call-process cleanups.
* callproc.c (Fcall_process): Do record-unwind-protect on MSDOS at the same time as other platforms, to simplify analysis. No need for fd0_volatile since we have synch_process_fd. Avoid needless emacs_close; arg is always negative.
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 2cc395428f8..2c3d31ba052 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -579,13 +579,20 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
579 } 579 }
580 else 580 else
581 fd0 = -1; /* We are not going to read from tempfile. */ 581 fd0 = -1; /* We are not going to read from tempfile. */
582#else /* not MSDOS */ 582#endif /* MSDOS */
583 583
584 /* Do the unwind-protect now, even though the pid is not known, so 584 /* Do the unwind-protect now, even though the pid is not known, so
585 that no storage allocation is done in the critical section. 585 that no storage allocation is done in the critical section.
586 The actual PID will be filled in during the critical section. */ 586 The actual PID will be filled in during the critical section. */
587 synch_process_pid = 0; 587 synch_process_pid = 0;
588 synch_process_fd = fd0; 588 synch_process_fd = fd0;
589
590#ifdef MSDOS
591 /* MSDOS needs different cleanup information. */
592 record_unwind_protect (call_process_cleanup,
593 Fcons (Fcurrent_buffer (),
594 build_string (tempfile ? tempfile : "")));
595#else
589 record_unwind_protect (call_process_cleanup, Fcurrent_buffer ()); 596 record_unwind_protect (call_process_cleanup, Fcurrent_buffer ());
590 597
591 block_input (); 598 block_input ();
@@ -603,7 +610,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
603 bool volatile display_p_volatile = display_p; 610 bool volatile display_p_volatile = display_p;
604 bool volatile output_to_buffer_volatile = output_to_buffer; 611 bool volatile output_to_buffer_volatile = output_to_buffer;
605 bool volatile sa_must_free_volatile = sa_must_free; 612 bool volatile sa_must_free_volatile = sa_must_free;
606 int volatile fd0_volatile = fd0;
607 int volatile fd1_volatile = fd1; 613 int volatile fd1_volatile = fd1;
608 int volatile fd_error_volatile = fd_error; 614 int volatile fd_error_volatile = fd_error;
609 int volatile fd_output_volatile = fd_output; 615 int volatile fd_output_volatile = fd_output;
@@ -621,7 +627,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
621 display_p = display_p_volatile; 627 display_p = display_p_volatile;
622 output_to_buffer = output_to_buffer_volatile; 628 output_to_buffer = output_to_buffer_volatile;
623 sa_must_free = sa_must_free_volatile; 629 sa_must_free = sa_must_free_volatile;
624 fd0 = fd0_volatile;
625 fd1 = fd1_volatile; 630 fd1 = fd1_volatile;
626 fd_error = fd_error_volatile; 631 fd_error = fd_error_volatile;
627 fd_output = fd_output_volatile; 632 fd_output = fd_output_volatile;
@@ -629,6 +634,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
629 count = count_volatile; 634 count = count_volatile;
630 sa_count = sa_count_volatile; 635 sa_count = sa_count_volatile;
631 new_argv = new_argv_volatile; 636 new_argv = new_argv_volatile;
637
638 fd0 = synch_process_fd;
632 } 639 }
633 640
634 if (pid == 0) 641 if (pid == 0)
@@ -682,18 +689,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
682 } 689 }
683 690
684 if (INTEGERP (buffer)) 691 if (INTEGERP (buffer))
685 { 692 return unbind_to (count, Qnil);
686 if (fd0 >= 0)
687 emacs_close (fd0);
688 return unbind_to (count, Qnil);
689 }
690
691#if defined (MSDOS)
692 /* MSDOS needs different cleanup information. */
693 record_unwind_protect (call_process_cleanup,
694 Fcons (Fcurrent_buffer (),
695 build_string (tempfile ? tempfile : "")));
696#endif
697 693
698 if (BUFFERP (buffer)) 694 if (BUFFERP (buffer))
699 Fset_buffer (buffer); 695 Fset_buffer (buffer);