From dfa1a9e3850bfd2da0072434a13dd145799ead43 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Wed, 18 Oct 2017 09:39:05 +0900 Subject: [PATCH] Fix process termination. Enable jongjmp to call termination processes after catching signals. --- CMakeLists.txt | 4 ++++ cmake/config.h.cmake | 6 +++++- src/param.c | 5 +++++ src/ypspur-coordinator.c | 10 ++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a28493..78f8ddf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,10 @@ if(USE_SSM) find_package(SSM) endif(USE_SSM) +include(CheckFunctionExists) +check_function_exists(longjmp HAVE_LONGJMP) +check_function_exists(siglongjmp HAVE_SIGLONGJMP) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/include/config.h ) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 45ad6e5..ffed201 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -11,6 +11,10 @@ #cmakedefine YP_PARAMS_DIR "@YP_PARAMS_DIR@" -#cmakedefine HAVE_SSM "@HAVE_SSM@" +#cmakedefine HAVE_SSM @HAVE_SSM@ + +#cmakedefine HAVE_LONGJMP @HAVE_LONGJMP@ + +#cmakedefine HAVE_SIGLONGJMP @HAVE_SIGLONGJMP@ #endif diff --git a/src/param.c b/src/param.c index 04cf8df..b63a929 100644 --- a/src/param.c +++ b/src/param.c @@ -371,6 +371,11 @@ int parameter_set( char param, char id, long long int value64 ) } value = value64; + if( option( OPTION_WITHOUT_DEVICE ) ) + { + return ( 0 ); + } + buf[0] = param; buf[1] = id; buf[2] = ( ( Int_4Char ) value ).byte[3]; diff --git a/src/ypspur-coordinator.c b/src/ypspur-coordinator.c index 7b72f26..e223d45 100644 --- a/src/ypspur-coordinator.c +++ b/src/ypspur-coordinator.c @@ -61,7 +61,10 @@ BOOL WINAPI win32_ctrlc_handler( DWORD type ) if( !option( OPTION_WITHOUT_SSM ) ) end_ypspurSSM( ); #endif - serial_close( ); + if( !( option( OPTION_WITHOUT_DEVICE ) ) ) + { + serial_close( ); + } return TRUE; } @@ -80,7 +83,10 @@ void emergency( int sig ) if( !option( OPTION_WITHOUT_SSM ) ) end_ypspurSSM( ); #endif - serial_close( ); + if( !( option( OPTION_WITHOUT_DEVICE ) ) ) + { + serial_close( ); + } exit( 0 ); #endif