[Lcdproc] [Patch] Ignore SIGPIPE on the server
Peter McCurdy
peter.mccurdy@gmail.com
Fri Mar 2 17:35:02 2007
------=_Part_105283_30353699.1172856860936
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
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.
I threw in a fix for the Windows port as well, but I haven't tested
it. It looks pretty straightforward though.
Thanks.
Peter.
------=_Part_105283_30353699.1172856860936
Content-Type: application/octet-stream; name=ignore-sigpipe.patch
Content-Transfer-Encoding: base64
X-Attachment-Id: f_eyswma86
Content-Disposition: attachment; filename="ignore-sigpipe.patch"
ZGlmZiAtcnVOIG9yaWctbGNkcHJvYy0wLjUuMS9zZXJ2ZXIvbWFpbi5jIG5ldy1sY2Rwcm9jLTAu
NS4xL3NlcnZlci9tYWluLmMKLS0tIG9yaWctbGNkcHJvYy0wLjUuMS9zZXJ2ZXIvbWFpbi5jCTIw
MDYtMTAtMDYgMDM6MDI6NDcuMDAwMDAwMDAwIC0wNDAwCisrKyBuZXctbGNkcHJvYy0wLjUuMS9z
ZXJ2ZXIvbWFpbi5jCTIwMDctMDMtMDIgMTI6MjI6MDEuMDAwMDAwMDAwIC0wNTAwCkBAIC01Mzks
OCArNTM5LDE0IEBACiAKIAlkZWJ1ZyggUlBUX0RFQlVHLCAiJXMoIGFsbG93X3JlbG9hZD0lZCAp
IiwgX19GVU5DVElPTl9fLCBhbGxvd19yZWxvYWQgKTsKIAotCXNhLnNhX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