linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] shared/shell: don't hook io_hup on non-interactive
@ 2020-05-27  5:02 Stimim Chen
  2020-05-27 17:13 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Stimim Chen @ 2020-05-27  5:02 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz; +Cc: chromeos-bluetooth-upstreaming, 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(-)

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-27 17:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27  5:02 [PATCH] shared/shell: don't hook io_hup on non-interactive Stimim Chen
2020-05-27 17:13 ` Luiz Augusto von Dentz

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).