From ad9585b7a6671903cadcf6c74491646736db8e1e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 25 Oct 2016 09:41:55 +0200 Subject: [PATCH] Check the return value of writing to the eventfd. --- alsa_pool.cpp | 5 ++++- midi_mapper.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/alsa_pool.cpp b/alsa_pool.cpp index 3b6dd7e..bcda163 100644 --- a/alsa_pool.cpp +++ b/alsa_pool.cpp @@ -41,7 +41,10 @@ ALSAPool::~ALSAPool() } should_quit = true; const uint64_t one = 1; - write(should_quit_fd, &one, sizeof(one)); + if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { + perror("write(should_quit_fd)"); + exit(1); + } inotify_thread.join(); while (retry_threads_running > 0) { diff --git a/midi_mapper.cpp b/midi_mapper.cpp index 4f8c33b..a819796 100644 --- a/midi_mapper.cpp +++ b/midi_mapper.cpp @@ -51,7 +51,10 @@ MIDIMapper::~MIDIMapper() { should_quit = true; const uint64_t one = 1; - write(should_quit_fd, &one, sizeof(one)); + if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { + perror("write(should_quit_fd)"); + exit(1); + } midi_thread.join(); close(should_quit_fd); } -- 2.39.2