Re: [PATCH BlueZ] core: Ignore SIGPIPE

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

 



Hi Gal,

On Fri, Nov 16, 2018 at 9:17 PM Gal Ben-Haim <gbenhaim@xxxxxxxxxx> wrote:
>
> 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".

Ive been suggesting using MSG_NOSIGNAL, do you have anything against it?

MSG_NOSIGNAL (since Linux 2.2)Requests not to send SIGPIPE on errors
on stream oriented sockets when the other end breaks the connection.
The EPIPE error is still returned.
(https://linux.die.net/man/2/send)

> ---
>  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);
>
>         __btd_log_init(option_debug, option_detach);
>
> @@ -809,7 +813,7 @@ int main(int argc, char *argv[])
>
>         sd_notify(0, "STATUS=Quitting");
>
> -       g_source_remove(signal);
> +       g_source_remove(signal_source);
>
>         plugin_cleanup();
>
> --
> 2.19.1
>


-- 
Luiz Augusto von Dentz



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux