From f560123f3e9254d90091b2aa4e839268ec1936a9 Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Sun, 30 Apr 2017 15:24:09 +0200 Subject: Move break handler modification Move them right before the loop, as before a break (e.g. while waiting for the audio decoder opening the pipe) didn't lead to termination. --- src/odr-padenc.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/odr-padenc.cpp') diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 2fd3a47..8a873fa 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -159,20 +159,6 @@ static bool read_slides_dir(const std::string& dir, History& history, std::list< int main(int argc, char *argv[]) { - // handle signals - if(signal(SIGINT, break_handler) == SIG_ERR) { - perror("ODR-PadEnc Error: could not set SIGINT handler"); - return 1; - } - if(signal(SIGTERM, break_handler) == SIG_ERR) { - perror("ODR-PadEnc Error: could not set SIGTERM handler"); - return 1; - } - if(signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - perror("ODR-PadEnc Error: could not set SIGPIPE to be ignored"); - return 1; - } - size_t padlen = 58; bool erase_after_tx = false; int sleepdelay = SLEEPDELAY_DEFAULT; @@ -331,6 +317,20 @@ int main(int argc, char *argv[]) { std::chrono::steady_clock::time_point next_run = std::chrono::steady_clock::now(); + // handle signals + if(signal(SIGINT, break_handler) == SIG_ERR) { + perror("ODR-PadEnc Error: could not set SIGINT handler"); + return 1; + } + if(signal(SIGTERM, break_handler) == SIG_ERR) { + perror("ODR-PadEnc Error: could not set SIGTERM handler"); + return 1; + } + if(signal(SIGPIPE, SIG_IGN) == SIG_ERR) { + perror("ODR-PadEnc Error: could not set SIGPIPE to be ignored"); + return 1; + } + while(!do_exit) { // try to read slides dir (if present) if (sls_dir && slides_to_transmit.empty()) { -- cgit v1.2.3