Mercurial > hg > octave-lyh
comparison src/toplev.cc @ 2693:f4d0604cbcc4
[project @ 1997-02-18 15:25:21 by jwe]
author | jwe |
---|---|
date | Tue, 18 Feb 1997 15:25:23 +0000 |
parents | 25fbbe6074e9 |
children | eb2ade3c6609 |
comparison
equal
deleted
inserted
replaced
2692:25fbbe6074e9 | 2693:f4d0604cbcc4 |
---|---|
68 #include "pt-fvc.h" | 68 #include "pt-fvc.h" |
69 #include "pt-misc.h" | 69 #include "pt-misc.h" |
70 #include "pt-plot.h" | 70 #include "pt-plot.h" |
71 #include "sighandlers.h" | 71 #include "sighandlers.h" |
72 #include "sysdep.h" | 72 #include "sysdep.h" |
73 #include "syswait.h" | |
73 #include "toplev.h" | 74 #include "toplev.h" |
74 #include "unwind-prot.h" | 75 #include "unwind-prot.h" |
75 #include "utils.h" | 76 #include "utils.h" |
76 #include "variables.h" | 77 #include "variables.h" |
77 #include <version.h> | 78 #include <version.h> |
647 return retval; | 648 return retval; |
648 } | 649 } |
649 | 650 |
650 // Execute a shell command. | 651 // Execute a shell command. |
651 | 652 |
653 static sigset_t signal_set, old_signal_set; | |
654 | |
652 static void | 655 static void |
653 cleanup_iprocstream (void *p) | 656 cleanup_iprocstream (void *p) |
654 { | 657 { |
658 UNBLOCK_CHILD (old_signal_set); | |
659 | |
655 delete (iprocstream *) p; | 660 delete (iprocstream *) p; |
656 } | 661 } |
657 | 662 |
658 static octave_value_list | 663 static octave_value_list |
659 run_command_and_return_output (const string& cmd_str) | 664 run_command_and_return_output (const string& cmd_str) |
660 { | 665 { |
661 octave_value_list retval; | 666 octave_value_list retval; |
667 | |
668 BLOCK_CHILD (signal_set, old_signal_set); | |
662 | 669 |
663 iprocstream *cmd = new iprocstream (cmd_str.c_str ()); | 670 iprocstream *cmd = new iprocstream (cmd_str.c_str ()); |
664 | 671 |
665 add_unwind_protect (cleanup_iprocstream, cmd); | 672 add_unwind_protect (cleanup_iprocstream, cmd); |
666 | 673 |
678 | 685 |
679 // The value in status is as returned by waitpid. If the | 686 // The value in status is as returned by waitpid. If the |
680 // process exited normally, extract the actual exit status of | 687 // process exited normally, extract the actual exit status of |
681 // the command. Otherwise, return 127 as a failure code. | 688 // the command. Otherwise, return 127 as a failure code. |
682 | 689 |
683 if ((status & 0xff) == 0) | 690 if (WIFEXITED (status)) |
684 status = (status >> 8) & 0xff; | 691 status = WEXITSTATUS (status); |
685 | 692 |
686 output_buf << ends; | 693 output_buf << ends; |
687 | 694 |
688 char *msg = output_buf.str (); | 695 char *msg = output_buf.str (); |
689 | 696 |
785 // The value in status is as returned by waitpid. If | 792 // The value in status is as returned by waitpid. If |
786 // the process exited normally, extract the actual exit | 793 // the process exited normally, extract the actual exit |
787 // status of the command. Otherwise, return 127 as a | 794 // status of the command. Otherwise, return 127 as a |
788 // failure code. | 795 // failure code. |
789 | 796 |
790 if ((status & 0xff) == 0) | 797 if (WIFEXITED (status)) |
791 status = (status >> 8) & 0xff; | 798 status = WEXITSTATUS (status); |
792 | 799 |
793 retval = (double) status; | 800 retval = (double) status; |
794 } | 801 } |
795 } | 802 } |
796 } | 803 } |