From 7bbf7c2b283a1e0c85fcb5fac2c7c1da0a474d4d Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 15 Jul 2014 12:30:36 +0200 Subject: [PATCH] monitor: Exit with error if failed to open file for writing --- monitor/control.c | 4 +++- monitor/control.h | 2 +- monitor/main.c | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/monitor/control.c b/monitor/control.c index 9e30d38de..879e19572 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -996,9 +996,11 @@ void control_server(const char *path) server_fd = fd; } -void control_writer(const char *path) +bool control_writer(const char *path) { btsnoop_file = btsnoop_create(path, BTSNOOP_TYPE_MONITOR); + + return !!btsnoop_file; } void control_reader(const char *path) diff --git a/monitor/control.h b/monitor/control.h index 8de4c6c6d..28f16db25 100644 --- a/monitor/control.h +++ b/monitor/control.h @@ -24,7 +24,7 @@ #include -void control_writer(const char *path); +bool control_writer(const char *path); void control_reader(const char *path); void control_server(const char *path); int control_tracing(void); diff --git a/monitor/main.c b/monitor/main.c index d4e8e6d5c..f0922ebbd 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -198,8 +198,10 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } - if (writer_path) - control_writer(writer_path); + if (writer_path && !control_writer(writer_path)) { + printf("Failed to open '%s'\n", writer_path); + return EXIT_FAILURE; + } if (ellisys_server) ellisys_enable(ellisys_server, ellisys_port); -- 2.47.3