dev-lang/crystal: Workaround tty corruption in crystal, bug #616256
authorSergei Trofimovich <slyfox@gentoo.org>
Sun, 23 Apr 2017 21:39:02 +0000 (22:39 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Sun, 23 Apr 2017 21:39:21 +0000 (22:39 +0100)
Patch restores blocking mode of file desriptors in exchange
of potential runtime deadlocks when dealing with stdio.

As it's a potentially invasive patch it's not enabled by default
and is available only under USE=blocking-stdio-hack

Reported-by: Renich Bon Ciric
Bug: https://github.com/crystal-lang/crystal/issues/2065
Bug: https://bugs.gentoo.org/616256
Package-Manager: Portage-2.3.5, Repoman-2.3.2

dev-lang/crystal/crystal-0.22.0.ebuild
dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch [new file with mode: 0644]
dev-lang/crystal/metadata.xml

index 91cd89b0f5af9176806ead6f5efc9e99ee951f66..219789c6b1cd4d49f62a88e66cfb8a77eeaeacc7 100644 (file)
@@ -18,7 +18,7 @@ SRC_URI="https://github.com/crystal-lang/crystal/archive/${PV}.tar.gz -> ${P}.ta
 LICENSE="Apache-2.0"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="doc debug examples +xml +yaml"
+IUSE="doc debug examples blocking-stdio-hack +xml +yaml"
 
 # dev-libs/boehm-gc[static-libs] dependency problem,  check the issue: https://github.com/manastech/crystal/issues/1382
 DEPEND="
@@ -41,6 +41,12 @@ PATCHES=(
        "${FILESDIR}"/${PN}-0.20.5-LDFLAGS.patch
 )
 
+src_prepare() {
+       default
+
+       use blocking-stdio-hack && eapply "${FILESDIR}"/"${PN}"-0.22.0-blocking-stdio-hack.patch
+}
+
 src_compile() {
        emake \
                $(usex debug "" release=1) \
diff --git a/dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch b/dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch
new file mode 100644 (file)
index 0000000..07b7dba
--- /dev/null
@@ -0,0 +1,20 @@
+Workaround tty corruption in crystal.
+
+Patch restores blocking mode of file desriptors
+in exchange of potential runtime deadlocks
+when dealing with stdio.
+
+Reported-by: Renich Bon Ciric
+Bug: https://github.com/crystal-lang/crystal/issues/2065
+Bug: https://bugs.gentoo.org/616256
+diff --git a/src/compiler/crystal/stdio.cr b/src/compiler/crystal/stdio.cr
+new file mode 100644
+index 000000000..e65f65089
+--- /dev/null
++++ b/src/compiler/crystal/stdio.cr
+@@ -0,0 +1,5 @@
++module Crystal
++  STDIN.blocking = true
++  STDOUT.blocking=true
++  STDERR.blocking = true
++end
index 80b55be2293ed95b2e1672304155bc1200cb19d3..8c0dacece652f6ecda642ebf35bab867a6075dc8 100644 (file)
@@ -22,6 +22,9 @@
                <flag name="debug">
                        Build each module as a separate object file. Speeds build up.
                </flag>
+               <flag name="blocking-stdio-hack">
+                       Keep STDIO file descriptors in blocking mode.
+               </flag>
                <flag name="yaml">
                        Use the <pkg>dev-libs/libyaml</pkg> library to enable Crystal yaml
                        module