diff mbox series

shared/shell: don't hook io_hup on non-interactive

Message ID 20200527050228.117532-1-stimim@google.com (mailing list archive)
State New, archived
Headers show
Series shared/shell: don't hook io_hup on non-interactive | expand

Commit Message

Stimim Chen May 27, 2020, 5:02 a.m. UTC
When we are in non-interactive mode (data.mode == 1), we should not
terminate the mainloop when stdin is disconnected.

For example, in bash, the following command would terminate immediately
without any output.

  : | btmgmt info

---
 src/shared/shell.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Luiz Augusto von Dentz May 27, 2020, 5:13 p.m. UTC | #1
Hi Stimim,

On Tue, May 26, 2020 at 10:02 PM Stimim Chen <stimim@google.com> wrote:
>
> When we are in non-interactive mode (data.mode == 1), we should not
> terminate the mainloop when stdin is disconnected.
>
> For example, in bash, the following command would terminate immediately
> without any output.
>
>   : | btmgmt info
>
> ---
>  src/shared/shell.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/shared/shell.c b/src/shared/shell.c
> index 2e094b8f1..d58e2d7d1 100644
> --- a/src/shared/shell.c
> +++ b/src/shared/shell.c
> @@ -1277,10 +1277,10 @@ bool bt_shell_attach(int fd)
>
>         io = io_new(fd);
>
> -       if (!data.mode)
> +       if (!data.mode) {
>                 io_set_read_handler(io, input_read, NULL, NULL);
> -
> -       io_set_disconnect_handler(io, io_hup, NULL, NULL);
> +               io_set_disconnect_handler(io, io_hup, NULL, NULL);
> +       }
>
>         data.input = io;
>
> --
> 2.27.0.rc0.183.gde8f92d652-goog

Applied, thanks.
diff mbox series

Patch

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 2e094b8f1..d58e2d7d1 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1277,10 +1277,10 @@  bool bt_shell_attach(int fd)
 
 	io = io_new(fd);
 
-	if (!data.mode)
+	if (!data.mode) {
 		io_set_read_handler(io, input_read, NULL, NULL);
-
-	io_set_disconnect_handler(io, io_hup, NULL, NULL);
+		io_set_disconnect_handler(io, io_hup, NULL, NULL);
+	}
 
 	data.input = io;