shared/shell: don't hook io_hup on non-interactive
authorStimim Chen <stimim@google.com>
Wed, 27 May 2020 05:02:28 +0000 (13:02 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:49 +0000 (14:30 +0530)
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

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/shared/shell.c

index 39f9a23..e92e46a 100644 (file)
@@ -1276,10 +1276,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;