I may have found a fix for the reader bug that occured recently.
http://bugs.call-cc.org/ticket/1269

It seems to be caused by an implementation-dependent behaviour of the
exit(3) procedure.

The bug occurs reliably on musl 1.1.12 and glibc 2.23

Here is a patch that make `make check` pass, as well as the
scsh-process’ tests for both incriminated libc


>From 5e4195073e46794e0127435bad53a0c4947e7b91 Mon Sep 17 00:00:00 2001
From: Kooda <ko...@upyum.com>
Date: Sat, 19 Mar 2016 13:21:43 +0100
Subject: [PATCH] Fix bug #1269

---
 posixunix.scm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/posixunix.scm b/posixunix.scm
index f56960d..bae028d 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -1576,6 +1576,12 @@ EOF
       (let ((pid (fork)))
        (when (fx= -1 pid) 
          (posix-error #:process-error 'process-fork "cannot create child 
process"))
+       ;; exit the child process gracefully when (exit) is called
+       (##sys#exit-handler
+        (lambda (#!optional (code 0))
+          ((foreign-lambda int "fflush" c-pointer) #f) ;; flush all output 
buffers
+          (##sys#cleanup-before-exit)
+          ((foreign-lambda void "_exit" int) code)))
        (if (and thunk (zero? pid))
            ((if killothers
                 ##sys#kill-other-threads
-- 
2.1.4

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to