[Lcdproc] [Patch] Ignore SIGPIPE on the server

Peter McCurdy peter.mccurdy@gmail.com
Sat Mar 3 21:42:01 2007


On 3/3/07, Peter Marschall <peter@adpm.de> wrote:
> Hi,
>
> On Friday, 2. March 2007 18:34, Peter McCurdy wrote:
> > For the past few days I've been wondering why LCDd sometimes quits
> > when I close my client.  Today I discovered it's because the server
> > doesn't ignore SIGPIPE.  If the server ever attempts to write to a
> > socket where the client has silently disappeared (which can happen
> > even with well-behaved clients), it'll receive SIGPIPE, and the
> > default action for SIGPIPE is to terminate the process.  This default
> > makes sense for standard Unix pipeline commands, but is obviously a
> > terrible setting for a server.
> >
> > This patch gets the server to ignore SIGPIPE, since it already
> > properly handles the error from writing to the socket.  After applying
> > this patch, if you run "killall -PIPE LCDd", the server will continue
> > to run, whereas before it would exit.  More to the point, if you run
> > "killall -KILL lcdproc", the server will always continue to run.
>
> Committed to CVS.
>
> I never experienced the problem on my i386 Debian installation
> though I often kill clients in mid-operation.
> What system do you use?

This was on CentOS 4, a clone of Red Hat Enterprise 4, mainly run
under VMware.  Note that it depends on the client; you only get
SIGPIPE if the server tries to write to a pipe whose other side has
disappeared.  I made my client send a "bye" command out of courtesy
just before it exits, which it turns out is a perfect way to generate
SIGPIPE when the server responds to the "bye".  Even then it wasn't
guaranteed, and in particular it was especially rare when I ran the
server under gdb.

Peter