diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 7d1d7d4..fb45d04 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
static bool discovery = false;
static bool resolve_names = true;
static bool interactive = false;
-static int exit_status = EXIT_SUCCESS;
static char *saved_prompt = NULL;
static int saved_point = 0;
if (interactive)
return;
- exit_status = status;
- mainloop_quit();
+ if (status == EXIT_SUCCESS)
+ mainloop_exit_success();
+ else
+ mainloop_exit_failure();
}
#define print(fmt, arg...) do { \
mgmt_index = index;
status = mainloop_run();
- if (status != EXIT_SUCCESS)
- exit_status = status;
if (input) {
io_destroy(input);
bt_gap_unref(gap);
- return exit_status;
+ return status;
}