Skip to contentSkip to conversation

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

PATCH Applied Stimim Chen 2 participants 2 messages May 27, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

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

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(-)
src/shared/shell.c +3 -3
index 2e094b8f1..d58e2d7d1 100644
@@ -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;
 
Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog
maintainer Applied
#1 lore raw

Hi Stimim,

Quoted 32 lines · Stimim Chen

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(-)
src/shared/shell.c +3 -4
index 2e094b8f1..d58e2d7d1 100644
@@ -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;
 
--
Quoted 1 line

2.27.0.rc0.183.gde8f92d652-goog

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz