#include <cassert>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <new>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include "cmd-edit.h"
#include "cmd-hist.h"
#include "file-ops.h"
#include "lo-error.h"
#include "lo-mappers.h"
#include "oct-env.h"
#include "oct-locbuf.h"
#include "quit.h"
#include "singleton-cleanup.h"
#include "str-vec.h"
#include "defaults.h"
#include "defun.h"
#include "error.h"
#include "file-io.h"
#include "graphics.h"
#include "input.h"
#include "lex.h"
#include "oct-conf.h"
#include "oct-hist.h"
#include "oct-map.h"
#include "oct-obj.h"
#include "ov.h"
#include "pager.h"
#include "parse.h"
#include "pathsearch.h"
#include "procstream.h"
#include "pt-eval.h"
#include "pt-jump.h"
#include "pt-stmt.h"
#include "sighandlers.h"
#include "sysdep.h"
#include "syswait.h"
#include "toplev.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"
#include "version.h"
Go to the source code of this file.
Enumerations | |
enum | system_exec_type { et_sync, et_async } |
Functions | |
void | clean_up_and_exit (int retval) |
DEFALIAS (exit, quit) | |
DEFUN (system, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} system (\"@var{string}\")\n\ @deftypefnx {Built-in Function} {} system (\"@var{string}\", @var{return_output})\n\ @deftypefnx {Built-in Function} {} system (\"@var{string}\", @var{return_output}, @var{type})\n\ @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} system (@dots{})\n\ Execute a shell command specified by @var{string}.\n\ If the optional argument @var{type} is \"async\", the process\n\ is started in the background and the process ID of the child process\n\ is returned immediately. Otherwise, the child process is started and\n\ Octave waits until it exits. If the @var{type} argument is omitted, it\n\ defaults to the value \"sync\".\n\ \n\ If @var{system} is called with one or more output arguments, or if the\n\ optional argument @var{return_output} is true and the subprocess is started\n\ synchronously, then the output from the command is returned as a variable. \n\ Otherwise, if the subprocess is executed synchronously, its output is sent\n\ to the standard output. To send the output of a command executed with\n\ @code{system} through the pager, use a command like\n\ \n\ @example\n\ @group\n\ [output, text] = system (\"cmd\");\n\ disp (text);\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ or\n\ \n\ @example\n\ printf (\"%s\\n\", nthargout (2, \"system\", \"cmd\"));\n\ @end example\n\ \n\ The @code{system} function can return two values. The first is the\n\ exit status of the command and the second is any output from the\n\ command that was written to the standard output stream. For example,\n\ \n\ @example\n\ [status, output] = system (\"echo foo; exit 2\");\n\ @end example\n\ \n\ @noindent\n\ will set the variable @code{output} to the string @samp{foo}, and the\n\ variable @code{status} to the integer @samp{2}.\n\ \n\ For commands run asynchronously, @var{status} is the process id of the\n\ command shell that is started to run the command.\n\ @seealso{unix, dos}\n\ @end deftypefn") | |
DEFUN (quit, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} exit (@var{status})\n\ @deftypefnx {Built-in Function} {} quit (@var{status})\n\ Exit the current Octave session. If the optional integer value\n\ @var{status} is supplied, pass that value to the operating system as the\n\ Octave's exit status. The default value is zero.\n\ @end deftypefn") | |
DEFUN (warranty,,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} warranty ()\n\ Describe the conditions for copying and distributing Octave.\n\ @end deftypefn") | |
DEFUN (atexit, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} atexit (@var{fcn})\n\ @deftypefnx {Built-in Function} {} atexit (@var{fcn}, @var{flag})\n\ Register a function to be called when Octave exits. For example,\n\ \n\ @example\n\ @group\n\ function last_words ()\n\ disp (\"Bye bye\");\n\ endfunction\n\ atexit (\"last_words\");\n\ @end group\n\ @end example\n\ \n\ @noindent\n\ will print the message \"Bye bye\" when Octave exits.\n\ \n\ The additional argument @var{flag} will register or unregister\n\ @var{fcn} from the list of functions to be called when Octave\n\ exits. If @var{flag} is true, the function is registered, and if\n\ @var{flag} is false, it is unregistered. For example,\n\ after registering the function @code{last_words} above,\n\ \n\ @example\n\ atexit (\"last_words\", false);\n\ @end example\n\ \n\ @noindent\n\ will remove the function from the list and Octave will not call\n\ @code{last_words} when it exits.\n\ \n\ Note that @code{atexit} only removes the first occurrence of a function\n\ from the list, so if a function was placed in the list multiple\n\ times with @code{atexit}, it must also be removed from the list\n\ multiple times.\n\ @end deftypefn") | |
DEFUN (octave_config_info, args,,"-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} octave_config_info ()\n\ @deftypefnx {Built-in Function} {} octave_config_info (@var{option})\n\ Return a structure containing configuration and installation\n\ information for Octave.\n\ \n\ If @var{option} is a string, return the configuration information for the\n\ specified option.\n\ \n\ @end deftypefn") | |
void | do_octave_atexit (void) |
int | main_loop (void) |
void | octave_add_atexit_function (const std::string &fname) |
bool | octave_remove_atexit_function (const std::string &fname) |
void | recover_from_exception (void) |
static octave_value_list | run_command_and_return_output (const std::string &cmd_str) |
static int | wait_for_input (int fid) |
Variables | |
static const char * | bt_fieldnames [] |
static const octave_fields | bt_fields (bt_fieldnames) |
int | exit_status = 0 |
tree_statement_list * | global_command = 0 |
std::list< std::string > | octave_atexit_functions |
void(* | octave_exit )(int) = ::exit |
bool | octave_initialized = false |
bool | octave_interpreter_ready = false |
bool | quit_allowed = true |
bool | quitting_gracefully = false |
enum system_exec_type |
void clean_up_and_exit | ( | int | retval | ) |
Definition at line 668 of file toplev.cc.
References do_octave_atexit(), and octave_exit.
Referenced by execute_eval_option_code(), main_loop(), octave_main(), and safe_source_file().
DEFALIAS | ( | exit | , | |
quit | ||||
) |
DEFUN | ( | system | , | |
args | , | |||
nargout | ||||
) |
Definition at line 827 of file toplev.cc.
References error(), error_state, et_async, et_sync, OCTAVE_LOCAL_BUFFER, panic_impossible, print_usage(), run_command_and_return_output(), WEXITSTATUS, and WIFEXITED.
DEFUN | ( | quit | , | |
args | ||||
) |
Definition at line 676 of file toplev.cc.
References error(), error_state, octave_interrupt_state, octave_throw_interrupt_exception(), quit_allowed, and quitting_gracefully.
DEFUN | ( | warranty | ) |
Definition at line 720 of file toplev.cc.
References octave_stdout.
DEFUN | ( | atexit | , | |
args | , | |||
nargout | ||||
) |
Definition at line 1127 of file toplev.cc.
References arg(), error(), error_state, octave_add_atexit_function(), octave_remove_atexit_function(), and print_usage().
DEFUN | ( | octave_config_info | , | |
args | ||||
) |
Definition at line 1207 of file toplev.cc.
References arg(), octave_scalar_map::assign(), octave_scalar_map::contents(), error(), error_state, oct_mach_info::float_format_as_string(), Array< T >::is_empty(), oct_mach_info::native_float_format(), print_usage(), subst_octave_home(), oct_mach_info::words_big_endian(), and oct_mach_info::words_little_endian().
void do_octave_atexit | ( | void | ) |
Definition at line 1023 of file toplev.cc.
References command_history::clean_up_and_save(), symbol_table::cleanup(), cleanup_parser(), cleanup_tmp_files(), octave_chunk_buffer::clear(), clear_mex_functions(), close_files(), feval(), flush_octave_stdout(), forced_interactive, command_history::ignoring_entries(), interactive, octave_atexit_functions, octave_history_write_timestamp(), OCTAVE_SAFE_CALL, octave_stdout, quitting_gracefully, raw_mode(), reset_error_handler(), command_editor::restore_terminal_state(), and sysdep_cleanup().
Referenced by clean_up_and_exit(), and octave_main().
int main_loop | ( | void | ) |
Definition at line 542 of file toplev.cc.
References tree_statement_list::accept(), unwind_protect::add_fcn(), symbol_table::at_top_level(), tree_break_command::breaking, can_interrupt, clean_up_and_exit(), cleanup_statement_list(), current_evaluator, error_state, forced_interactive, command_editor::increment_current_command_number(), interactive, octave_bad_alloc_hook, octave_catch_interrupts(), octave_completion_matches_called, octave_initialized, octave_interrupt_hook, octave_parse(), octave_save_signal_mask(), octave_signal_hook, octave_stdout, parser_end_of_input, unwind_protect::protect_var(), quitting_gracefully, recover_from_exception(), tree_evaluator::reset_debug_state(), reset_error_handler(), reset_parser(), tree_return_command::returning, symbol_table::top_scope(), and symbol_table::unmark_forced_variables().
Referenced by octave_main().
void octave_add_atexit_function | ( | const std::string & | fname | ) |
Definition at line 1102 of file toplev.cc.
References octave_atexit_functions.
Referenced by DEFUN().
bool octave_remove_atexit_function | ( | const std::string & | fname | ) |
Definition at line 1108 of file toplev.cc.
References octave_atexit_functions.
Referenced by DEFUN().
void recover_from_exception | ( | void | ) |
Definition at line 530 of file toplev.cc.
References can_interrupt, octave_catch_interrupts(), octave_exception_state, octave_interrupt_immediately, octave_interrupt_state, octave_restore_signal_mask(), and octave_signal_caught.
Referenced by execute_eval_option_code(), main_loop(), and safe_source_file().
static octave_value_list run_command_and_return_output | ( | const std::string & | cmd_str | ) | [static] |
Definition at line 773 of file toplev.cc.
References unwind_protect::add_delete(), unwind_protect::add_fcn(), procstreambase::close(), error(), procstreambase::file_number(), procstreambase::pid(), octave_child_list::remove(), wait_for_input(), WEXITSTATUS, and WIFEXITED.
Referenced by DEFUN().
Definition at line 751 of file toplev.cc.
Referenced by run_command_and_return_output().
const char* bt_fieldnames[] [static] |
const octave_fields bt_fields(bt_fieldnames) [static] |
Referenced by octave_call_stack::do_backtrace(), and octave_call_stack::empty_backtrace().
int exit_status = 0 |
Definition at line 88 of file toplev.cc.
Referenced by execute_eval_option_code(), and safe_source_file().
Definition at line 98 of file toplev.cc.
Referenced by get_debug_input().
std::list<std::string> octave_atexit_functions |
Definition at line 1020 of file toplev.cc.
Referenced by do_octave_atexit(), octave_add_atexit_function(), and octave_remove_atexit_function().
void(* octave_exit)(int) = ::exit |
Definition at line 80 of file toplev.cc.
Referenced by clean_up_and_exit().
bool octave_initialized = false |
Definition at line 95 of file toplev.cc.
Referenced by execute_command_line_file(), execute_eval_option_code(), main_loop(), and user_abort().
bool octave_interpreter_ready = false |
Definition at line 92 of file toplev.cc.
Referenced by execute_pkg_add_or_del(), and octave_main().
bool quit_allowed = true |
Definition at line 83 of file toplev.cc.
Referenced by DEFUN(), octave_main(), and octave_oncleanup::~octave_oncleanup().
bool quitting_gracefully = false |
Definition at line 86 of file toplev.cc.
Referenced by DEFUN(), do_octave_atexit(), execute_eval_option_code(), main_loop(), octave_main(), and safe_source_file().