changeset 14974:a6c44c28dabe gui

Added patch from jwe that forks the GUI process in order to have less work. * octave-gui.cc: Added forking before actually launching the GUI.
author Jacob Dawid <jacob.dawid@gmail.com>
date Thu, 19 Jul 2012 09:30:07 -0400
parents bc6c099eacc0
children 4daed35ff776
files gui/src/octave-gui.cc
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gui/src/octave-gui.cc
+++ b/gui/src/octave-gui.cc
@@ -25,6 +25,32 @@
 int
 main (int argc, char *argv[])
 {
+  /* dissociate from the controlling terminal, if any */
+
+  pid_t pid = fork ();
+  if (pid < 0)
+    {
+      //fprintf (stderr, "fork failed\n");
+      return 1;
+    }
+  else if (pid == 0)
+    {
+      /* child */
+      //fprintf (stderr, "in child, calling setsid ()\n");
+
+      if (setsid () < 0)
+        {
+          //fprintf (stderr, "setsid error\n");
+          return 1;
+        }
+    }
+  else
+    {
+      /* parent */
+      //fprintf (stderr, "in parent, exiting\n");
+      exit (0);
+    }
+
   QApplication application (argc, argv);
   while (true)
     {