# HG changeset patch # User John W. Eaton # Date 1380917422 14400 # Node ID 1c7d768c3847f01f336b6e62ba7bd5ccf41b402e # Parent 9d0992c6df30a54e02bab5bb6831c8f0b958164f 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. diff --git a/configure.ac b/configure.ac --- 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]) diff --git a/libinterp/octave.cc b/libinterp/octave.cc --- a/libinterp/octave.cc +++ b/libinterp/octave.cc @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -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, ,