diff --git a/src/tibridge.c b/src/tibridge.c index b6b55b4..778100a 100644 --- a/src/tibridge.c +++ b/src/tibridge.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "common/utils.h" @@ -85,7 +86,23 @@ void retry_recv(uint8_t* recv, int recvCount) { fflush(stdout); } +void cleanup() { + if(cable_handle) { + ticables_cable_close(cable_handle); + ticables_handle_del(cable_handle); + } + ticables_library_exit(); +} + +void handle_sigint(int code) { + cleanup(); +} + int main(int argc, char *argv[]) { + struct sigaction sa; + sa.sa_handler = handle_sigint; + sigaction(SIGINT, &sa, NULL); + // z88dk-gdb doesn't like the ACKs -/+, so we just hide them int handle_acks = 1;