Patch attempt for ticket #1269 added by Kooda on Sat Mar 19 13:23:47 2016

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

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

diff --git a/posixunix.scm b/posixunix.scm
index f56960d..5e3f5de 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -1576,6 +1576,11 @@ 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
+	   ((foreign-lambda void "_exit" int) code)))
 	(if (and thunk (zero? pid))
 	    ((if killothers
 		 ##sys#kill-other-threads
-- 
2.1.4