1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
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
@@ -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()
@@ -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; }
|