[racket] error writing to stream port (Broken pipe; errno=32)

From: Wolfgang Hukriede (whukriede at gmail.com)
Date: Fri Sep 12 15:57:30 EDT 2014

Hi Matthias, nice to meet you! Yes, this was what I was looking for.

For the records:

(define (epipe? x)
  (and
   (exn:fail:filesystem:errno? x) 
   (equal? '(32 . posix) (exn:fail:filesystem:errno-errno x))))

(define (epipe-handler x)
  "ignore")

(with-handlers
 ((epipe? epipe-handler))
 transput...)

Many thanks!

Results are mixed though. Usage like 

$ mzscheme --no-init-file --load pipetest.scm | head

mostly works okay, but depending on how and how much is written to
standard out and on the parameters to "head" failures reproducibly
occur: in some situations the signal is not caught, yielding a "system
error: Broken pipe; errno=32" message (versions 6.1 and 5.93 on
freebsd, and 4.1 on generic linux, 6.1 precompiled racket on
archlinux), or sometimes the pipe even just hangs (6.1 on freebsd).
These were the combinations I tried.
(On 4.1 exn:fail:filesystem was used instead of non-existing
exn:fail:filesystem:errno.)

Posted on the users mailing list.