Description: Tell Singular not to steal the TTY 
Origin: https://src.fedoraproject.org/rpms/qepcad-B/blob/91dd25b/f/qepcad-B-tty.patch
Bug: https://bugzilla.redhat.com/1257471
Forwarded: https://github.com/chriswestbrown/qepcad/pull/2
Last-Update: 2021-06-23

--- a/source/db/SINGULAR.c
+++ b/source/db/SINGULAR.c
@@ -1,6 +1,7 @@
 #include "SINGULAR.h"
 #include <iostream>
 #include <string>
+#include <unistd.h>
 using namespace std;
 
 
@@ -15,6 +16,12 @@
   if (childpid == 0) {
     intoSingular.setStdinToPipe();
     outofSingular.setStdoutToPipe();
+    outofSingular.setStderrToPipe();
+    intoSingular.closeIn();
+    intoSingular.closeOut();
+    outofSingular.closeIn();
+    outofSingular.closeOut();
+    setsid();
 
     // Begin: Just for debug!!
     //system("/home/wcbrown/bin/Singular -q --no-warn --min-time=0.001 --ticks-per-sec=1000 | tee /tmp/SingOutLog");
@@ -30,9 +37,10 @@
 	   "--ticks-per-sec=1000",
 	   NULL);
       perror("SingularServer Constructor: Singular startup failed! (Set SINGULAR environment variable)");
-      outofSingular.closeOut();
       exit(0);
   }
+  intoSingular.closeIn();
+  outofSingular.closeOut();
 }
 
 SingularServer::~SingularServer()
--- a/source/db/unnamedpipe.h
+++ b/source/db/unnamedpipe.h
@@ -113,6 +113,7 @@
   int fdout() { return fd[1]; }
   int setStdinToPipe() { return dup2(fdin(),fileno(stdin)); }
   int setStdoutToPipe() { return dup2(fdout(),fileno(stdout)); }
+  int setStderrToPipe() { return dup2(fdout(),fileno(stderr)); }
   void closeIn() { 
     if (_in) { delete _in; _in = 0; }
     if (openmask[0]) { close(fd[0]); openmask[0] = false; } 
