linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gal Ben Haim <gbenhaim@augury.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ] core: Ignore SIGPIPE
Date: Fri, 16 Nov 2018 22:11:57 +0200	[thread overview]
Message-ID: <CAHotPr-cE2gc9Gue9ekyqgb4fFCR+jPWuVYcQzNrpFc-BmW7-g@mail.gmail.com> (raw)
In-Reply-To: <5F365876-5DA6-4916-B810-E2DF1ABD3772@holtmann.org>

what should signal_handler do in case of SIGPIPE? will failed write
return EPIPE if the signal is catched?

On Fri, Nov 16, 2018 at 10:01 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Gal,
>
> > bluetoothd receives a SIGPIPE and terminates if writing to a pipe that
> > was acquired by AcquireNotify and there are no readers. it can be
> > reproduced by terminating the reader process without closing the reader
> > end of the pipe.
> >
> > Ignoring the SIGPIPE will cause the write operation to return an
> > error which will be logged as "io_send: Broken pipe".
> > ---
> > src/main.c | 10 +++++++---
> > 1 file changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/main.c b/src/main.c
> > index 4716f5388..c62886593 100644
> > --- a/src/main.c
> > +++ b/src/main.c
> > @@ -691,7 +691,7 @@ int main(int argc, char *argv[])
> >       uint16_t sdp_mtu = 0;
> >       uint32_t sdp_flags = 0;
> >       int gdbus_flags = 0;
> > -     guint signal, watchdog;
> > +     guint signal_source, watchdog;
> >       const char *watchdog_usec;
> >
> >       init_defaults();
> > @@ -721,7 +721,11 @@ int main(int argc, char *argv[])
> >
> >       event_loop = g_main_loop_new(NULL, FALSE);
> >
> > -     signal = setup_signalfd();
> > +     signal_source = setup_signalfd();
> > +
> > +     /* Ignore SIGPIPE, a broken pipe error will be returned from write
> > +      * attempts to a pipe with no readers */
> > +     signal(SIGPIPE, SIG_IGN);
>
> if we decide not to use MSG_NOSIGNAL, then everything has to go via signalfd and not just by hacking in signal(SIG_IGN).
>
> Regards
>
> Marcel
>

  reply	other threads:[~2018-11-16 20:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 19:14 [PATCH BlueZ] core: Ignore SIGPIPE Gal Ben-Haim
2018-11-16 19:30 ` Luiz Augusto von Dentz
2018-11-16 19:54   ` Gal Ben Haim
2018-11-16 20:01 ` Marcel Holtmann
2018-11-16 20:11   ` Gal Ben Haim [this message]
2018-11-16 23:45     ` Gal Ben Haim
2018-11-17  9:29       ` Luiz Augusto von Dentz
2018-11-17 15:04         ` Gal Ben Haim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHotPr-cE2gc9Gue9ekyqgb4fFCR+jPWuVYcQzNrpFc-BmW7-g@mail.gmail.com \
    --to=gbenhaim@augury.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).