If running bluetoothctl as a subprocess from another process, and piping input to it, it’s possible for the stdin pipe to be closed by the parent process while there’s still data pending in its buffer. This results in input handler callbacks with condition (G_IO_IN | G_IO_HUP). All of the pending input should be handled before closing bluetoothctl. --- client/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/main.c b/client/main.c index 0dd1510..0ec40c7 100644 --- a/client/main.c +++ b/client/main.c @@ -1197,12 +1197,16 @@ done: static gboolean input_handler(GIOChannel *channel, GIOCondition condition, gpointer user_data) { + if (condition & G_IO_IN) { + rl_callback_read_char(); + return TRUE; + } + if (condition & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) { g_main_loop_quit(main_loop); return FALSE; } - rl_callback_read_char(); return TRUE; } -- 1.8.3.1
Attachment:
signature.asc
Description: This is a digitally signed message part