mirror of https://github.com/sfeakes/AqualinkD.git
serial_logger: exit immediately upon SIGINT
It appears that `intHandler()` is designed to terminate the main loop by setting the `_keepRunning` flag. However, this logic is defective, as it assumes that the main loop will terminate within a reasonable time. This is not the case: (gdb) start (gdb) continue <CTRL-C> (gdb) signal SIGINT Continuing with signal SIGINT. Notice: Serial Log:Stopping! <CTRL-C> (gdb) backtrace 0 0x00007ffff7cea121 in read () from /lib64/libc.so.6 1 0x0000000000407002 in get_packet () 2 0x00000000004038b1 in _serial_logger () 3 0x00000000004026ed in main () The main loop gets stuck in a blocking call to `read()`. If there is no data coming via the serial port, `read()` never returns, and the porogram never exits. This behavior is quite problematic, as, intuitively, CTRL-C terminates most programs by sending SIGINT. To stop `serial_logger`, one generally needs to freeze the program with CTRL-Z, and then send SIGKILL to terminate it. I presume this is not the intended behavior of the main loopp. Fixing this behavior would require re-architecting the main loop to use asynchronous or non-blocking calls. For the short term, simply exit on SIGINT and SIGTERM.pull/375/head
parent
c2067be46e
commit
1e33750b52
|
@ -100,8 +100,7 @@ void broadcast_log(char *msg){
|
|||
void intHandler(int dummy) {
|
||||
_keepRunning = false;
|
||||
LOG(SLOG_LOG, LOG_NOTICE, "Stopping!\n");
|
||||
if (_playback_file) // If we are reading file, loop is irevelent
|
||||
exit(0);
|
||||
exit(0);
|
||||
}
|
||||
#else
|
||||
int serial_logger (int rs_fd, char *port_name, int logLevel, int slogger_packets, char *slogger_ids)
|
||||
|
|
Loading…
Reference in New Issue