[Date Prev][Date Next]
Re: SIGPIPE (again)
I really don't see this approach fixing much... but it may
break a few things. Note that send(2) only works for sockets
while write(2) works on most any kind of descriptor. While
normally the library is used with sockets, it can be used
with pipes, files, and such.
At 12:52 PM 8/8/2003, email@example.com wrote:
>I've been dealing w/ random programs crashing when the get
>SIGPIPE working it's way up from liblber->libldap->nss_ldap->etc
>(I use ldap as my nsswitch source).
>I see this has come up before, on Wed, 3 Apr 2002 Igor Brezac wrote:
>> I do not think that this is a bug because the socket can brake between the
>> test and the write() call. I tried several different ldap libs and they
>> behave the same in this particular example. The application needs to take
>> care of this with something simple like signal(SIGPIPE, SIG_IGN).
>This strategy won't work here, since pretty much every program could
>get the SIGPIPE.
>The general solution to this is for every OS to do the right thing and
>deliver SIGPIPE to the _thread_ that caused it. But, in the mean time
>on linux at least, there is another way. You can use send() instead
>of write, and add MSG_NOSIGNAL to the flags:
> This flag turns off raising of SIGPIPE on stream sockets when
> the other end disappears.
>I have patched my openldap to add a test for linux and define
>tcp_write/tcp_read to use send/recv w/ MSG_NOSIGNAL set, and then to
>fix the two places that call read/write directly to use tcp_write/tcp_read.
>Would this solution be generally acceptable to the openldap team?