comparison libinterp/octave.cc @ 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 1b388d922e6b
children c702371ff6df d63878346099
comparison
equal deleted inserted replaced
17569:9d0992c6df30 17570:1c7d768c3847
31 #include <cstring> 31 #include <cstring>
32 #include <ctime> 32 #include <ctime>
33 33
34 #include <iostream> 34 #include <iostream>
35 35
36 #include <fcntl.h>
36 #include <getopt.h> 37 #include <getopt.h>
37 #include <sys/types.h> 38 #include <sys/types.h>
38 #include <unistd.h> 39 #include <unistd.h>
39 40
40 #include "cmd-edit.h" 41 #include "cmd-edit.h"
1083 } 1084 }
1084 1085
1085 int 1086 int
1086 octave_fork_gui (void) 1087 octave_fork_gui (void)
1087 { 1088 {
1088 return ! no_fork_option; 1089 bool have_ctty = false;
1090
1091 #if ! (defined (__WIN32__) || defined (__APPLE__)) || defined (__CYGWIN__)
1092
1093 #if defined (HAVE_CTERMID)
1094 const char *ctty = ctermid (0);
1095 #else
1096 const char *ctty = "/dev/tty";
1097 #endif
1098
1099 have_ctty = gnulib::open (ctty, O_RDWR, 0) > 0;
1100
1101 #endif
1102
1103 return (have_ctty && ! no_fork_option);
1089 } 1104 }
1090 1105
1091 DEFUN (isguirunning, args, , 1106 DEFUN (isguirunning, args, ,
1092 "-*- texinfo -*-\n\ 1107 "-*- texinfo -*-\n\
1093 @deftypefn {Built-in Function} {} isguirunning ()\n\ 1108 @deftypefn {Built-in Function} {} isguirunning ()\n\