Fix total lockup (bz 1257471).

This consists of two separate changes:
- Run Singular in a separate session so it doesn't steal the TTY.
- Don't send data to bash through the (supposedly) Singular pipe.
This commit is contained in:
Jerry James 2015-09-03 20:03:08 -06:00
parent 9f4e1dba2c
commit 4dc2f4cc66
3 changed files with 64 additions and 5 deletions

View File

@ -1,11 +1,12 @@
--- ./source/main/BEGINQEPCAD.c.orig 2012-03-16 06:49:30.000000000 -0600
+++ ./source/main/BEGINQEPCAD.c 2013-07-18 16:57:34.694879193 -0600
@@ -98,7 +98,7 @@ void BEGINQEPCAD(int &argc, char**& argv
+++ ./source/main/BEGINQEPCAD.c 2015-09-03 19:50:14.594696632 -0600
@@ -98,7 +98,8 @@ void BEGINQEPCAD(int &argc, char**& argv
void QEPCAD_ProcessRC(int argc, char **argv)
{
char *qepath = getenv("qe");
- if (qepath == NULL) { FAIL("QEPCAD_ProcessRC","Environment variable qe not defined!"); }
+ if (qepath == NULL) { setenv("qe", "/usr/share/qepcad", 1); qepath = getenv("qe"); }
+ if (getenv("SINGULARPATH") == NULL) { setenv("SINGULARPATH", "@LIBDIR@/Singular", 1); }
string rcFileName = qepath + string("/default.qepcadrc");
ifstream rcin(rcFileName.c_str());
if (!rcin) { return; }

45
qepcad-B-tty.patch Normal file
View File

@ -0,0 +1,45 @@
--- ./source/db/SINGULAR.c.orig 2013-11-21 15:54:01.972430325 -0700
+++ ./source/db/SINGULAR.c 2015-09-03 19:42:46.612130230 -0600
@@ -1,6 +1,7 @@
#include "SINGULAR.h"
#include <iostream>
#include <string>
+#include <unistd.h>
using namespace std;
@@ -15,6 +16,12 @@ SingularServer::SingularServer(string Si
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 @@ SingularServer::SingularServer(string Si
"--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()
--- ./source/db/unnamedpipe.h.orig 2015-09-03 19:51:49.424196005 -0600
+++ ./source/db/unnamedpipe.h 2015-09-03 19:51:55.462718382 -0600
@@ -113,6 +113,7 @@ public:
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; }

View File

@ -1,12 +1,13 @@
Name: qepcad-B
Version: 1.69
Release: 10%{?dist}
Release: 11%{?dist}
Summary: Quantifier elimination tool
License: MIT
URL: http://www.usna.edu/CS/qepcadweb/INSTALL/IQ.html
Source0: http://www.usna.edu/CS/qepcadweb/INSTALL/%{name}.%{version}.tar.gz
# Don't require users to set the "qe" environment variable. Not for upstream.
# Don't require users to set the "qe" or "SINGULARPATH" environment variables.
# Not for upstream.
Patch0: %{name}-env.patch
# Add gcc attributes for better efficiency and warnings. Upstream: 20 Nov 2013.
Patch1: %{name}-attr.patch
@ -27,12 +28,16 @@ Patch6: %{name}-signed.patch
Patch7: %{name}-syntax.patch
# Remove unused variables and static functions.
Patch8: %{name}-unused.patch
# Tell Singular not to steal the TTY (bz 1257471)
Patch9: %{name}-tty.patch
BuildRequires: freeglut-devel
BuildRequires: readline-devel
BuildRequires: saclib-devel
# Subprocesses are spawned to run executables from these packages
Requires: bash
Requires: coreutils
Requires: Singular
%description
@ -55,10 +60,14 @@ development of the original that may proceed in a different direction.
%patch6
%patch7
%patch8
%patch9
# Adapt to the Fedora saclib package
sed -i 's,\${saclib}/lib/saclib.\.a,-lsaclib,' source/Makefile cad2d/Makefile
# Embed the library path
sed -i 's,@LIBDIR@,%{_libdir},' source/main/BEGINQEPCAD.c
# Use the right build flags
sed -i "s|-O4|%{optflags} -Wno-unused-label $RPM_LD_FLAGS|" plot2d/Makefile
@ -90,7 +99,7 @@ install -p -m 0755 cad2d/cad2d %{buildroot}%{_bindir}
# Install the default settings file
mkdir -p %{buildroot}%{_datadir}/qepcad
sed 's/^#S/S/' default.qepcadrc > \
sed 's,^#S.*,SINGULAR %{_libdir}/Singular,' default.qepcadrc > \
%{buildroot}%{_datadir}/qepcad/default.qepcadrc
touch -r default.qepcadrc %{buildroot}%{_datadir}/qepcad/default.qepcadrc
@ -110,6 +119,10 @@ ln -s %{_bindir}/qepcad %{buildroot}%{_datadir}/qepcad/bin
%{_datadir}/qepcad/
%changelog
* Thu Sep 3 2015 Jerry James <loganjerry@gmail.com> - 1.69-11
- Run Singular in a separate session so it doesn't steal the TTY (bz 1257471)
- Don't send data to bash through the (supposedly) Singular pipe
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.69-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild