Mercurial > hg > octave-nkf
changeset 17570:1c7d768c3847
don't fork if there is no controlling tty
* configure.ac: Check for ctermid.
* octave.cc (octave_fork_gui): Check for controlling tty and return
false one is not found.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 04 Oct 2013 16:10:22 -0400 |
parents | 9d0992c6df30 |
children | 6e4ea5c8a4bb |
files | configure.ac libinterp/octave.cc |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac +++ b/configure.ac @@ -2082,7 +2082,7 @@ dnl These checks define/undefine HAVE_FUNCNAME in config.h. dnl Code tests HAVE_FUNCNAME and either uses function or provides workaround. dnl Use multiple AC_CHECKs to avoid line continuations '\' in list -AC_CHECK_FUNCS([canonicalize_file_name dup2]) +AC_CHECK_FUNCS([canonicalize_file_name ctermid dup2]) AC_CHECK_FUNCS([endgrent endpwent execvp expm1 expm1f fork]) AC_CHECK_FUNCS([getegid geteuid getgid getgrent getgrgid getgrnam]) AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid])
--- a/libinterp/octave.cc +++ b/libinterp/octave.cc @@ -33,6 +33,7 @@ #include <iostream> +#include <fcntl.h> #include <getopt.h> #include <sys/types.h> #include <unistd.h> @@ -1085,7 +1086,21 @@ int octave_fork_gui (void) { - return ! no_fork_option; + bool have_ctty = false; + +#if ! (defined (__WIN32__) || defined (__APPLE__)) || defined (__CYGWIN__) + +#if defined (HAVE_CTERMID) + const char *ctty = ctermid (0); +#else + const char *ctty = "/dev/tty"; +#endif + + have_ctty = gnulib::open (ctty, O_RDWR, 0) > 0; + +#endif + + return (have_ctty && ! no_fork_option); } DEFUN (isguirunning, args, ,