client: Allow to terminate if bluetoothd was not started
PATCH 1/1 client: Allow to terminate if bluetoothd was not started
This allows to terminate bluetoothctl with CTRL-C if daemon didn't start. Otherwise input is not functional and user must kill bluetoothctl by sending signal from another terminal.
--- client/main.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
client/main.c +17 -6
@@ -60,6 +60,8 @@ static GDBusProxy *default_ctrl;static GList *ctrl_list;static GList *dev_list; +static guint input =0 ; +static const char *const agent_arguments[] = {"on" ,"off" ,
@@ -1386,11 +1388,20 @@ static gboolean signal_handler(GIOChannel *channel, GIOCondition condition,switch (si.ssi_signo) {case SIGINT : -rl_replace_line ("" ,0 ); -rl_crlf (); -rl_on_new_line (); -rl_redisplay (); -break ; +if (input) { +rl_replace_line ("" ,0 ); +rl_crlf (); +rl_on_new_line (); +rl_redisplay (); +break ; + } + +/* +* If input was not yet setup up that means signal was received +* while daemon was not yet running. Since user is not able +* to terminate client by CTRL-D or typing exit treat this as +* exit and fall through. +*/ case SIGTERM :if (__terminated ==0 ) {rl_replace_line ("" ,0 );
@@ -1476,7 +1487,7 @@ int main(int argc, char *argv[])GOptionContext *context;GError *error =NULL ;GDBusClient *client; -guint signal, input; +guint signal; context =g_option_context_new (NULL );g_option_context_add_main_entries (context, options,NULL );
Signature · 1 line
2.0.1
Johan Hedberg
AppliedHi Szymon,
Quoted 6 lines · Szymon Janc
This allows to terminate bluetoothctl with CTRL-C if daemon didn't start. Otherwise input is not functional and user must kill bluetoothctl by sending signal from another terminal.
--- client/main.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
Applied. Thanks.
Johan