[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: detecting broken pipe

From: Dan McMahill
Subject: Re: detecting broken pipe
Date: Mon, 24 Apr 2006 20:44:04 -0400
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7.6) Gecko/20050412

Kevin Ryde wrote:
Dan McMahill <address@hidden> writes:

So is there an easy way to detect when the pipe was terminated so I
can avoid crashing?

You can set the SIGPIPE signal to avoid terminating on a broken pipe.
Usually setting it to SIG_IGN is the cleanest, with that a write
throws an EPIPE error.  (Read more in the libc manual.)

As to actually detecting the termination, SIGCHLD might tell you as
soon as the child dies (though you probably have to be careful not to
interfere with the cleanups close-pipe will do).

I tried this:

(sigaction SIGPIPE SIG_IGN)


(set! pcb:pipe (open-output-pipe "pcb --listen"))

but when I exit out of pcb, I still get

ERROR: In procedure write_all:
ERROR: Broken pipe

For various reasons I prefer to do whatever magic needs doing to deal with this completely in scheme rather than in the c program which uses guile.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]