Mercurial > hg > octave-nkf
changeset 17780:8b353af4a1ca
allow octave main program to work on Windows systems
* main.in.cc: Simply exec octave-gui or octave-cli on Windows
systems.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 27 Oct 2013 23:13:45 -0400 |
parents | 9244d2a908fd |
children | d029ef208e4a |
files | src/main.in.cc |
diffstat | 1 files changed, 29 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.in.cc +++ b/src/main.in.cc @@ -39,19 +39,18 @@ #include <iostream> #include <string> -#include <sys/wait.h> -#include <sys/types.h> -#include <sys/signal.h> -#include <fcntl.h> +// From gnulib, so OK for Windows too. #include <unistd.h> -#ifndef OCTAVE_BINDIR -#define OCTAVE_BINDIR %OCTAVE_BINDIR% -#endif +#if ! defined (__WIN32__) && ! defined (__CYGWIN__) -#ifndef OCTAVE_PREFIX -#define OCTAVE_PREFIX %OCTAVE_PREFIX% -#endif +#include <sys/types.h> +#include <signal.h> +#include <fcntl.h> + +// This is a liboctave header, but it doesn't include any other Octave +// headers or declare any functions that are defined in liboctave. +#include "syswait.h" typedef void sig_handler (int); @@ -230,6 +229,16 @@ return retval; } +#endif + +#ifndef OCTAVE_BINDIR +#define OCTAVE_BINDIR %OCTAVE_BINDIR% +#endif + +#ifndef OCTAVE_PREFIX +#define OCTAVE_PREFIX %OCTAVE_PREFIX% +#endif + // Find the directory where the octave binary is supposed to be // installed. @@ -324,12 +333,6 @@ bool start_gui = true; bool cli_only = false; -#if defined (__WIN32__) || defined (__CYGWIN__) - bool no_fork_required = true; -#else - bool no_fork_required = false; -#endif - std::string octave_bindir = get_octave_bindir (); std::string file = octave_bindir + dir_sep_char + "octave-gui"; @@ -369,8 +372,13 @@ new_argv[k] = 0; - if (cli_only || no_fork_required - || (! start_gui && ! have_controlling_terminal ())) +#if defined (__WIN32__) || defined (__CYGWIN__) + + retval = octave_exec (file, new_argv); + +#else + + if (cli_only || (! start_gui && ! have_controlling_terminal ())) { retval = octave_exec (file, new_argv); } @@ -408,7 +416,7 @@ while (1) { - waitpid (gui_pid, &status, 0); + WAITPID (gui_pid, &status, 0); if (WIFEXITED (status)) { @@ -420,6 +428,8 @@ } } +#endif + return retval; }