Skip to content

Commit

Permalink
Fix process termination. (#49)
Browse files Browse the repository at this point in the history
Enable longjmp to call termination procedures after catching sigint.
  • Loading branch information
at-wat authored Oct 18, 2017
1 parent 18226b8 commit aaa9496
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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
)
Expand Down
6 changes: 5 additions & 1 deletion cmake/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
10 changes: 8 additions & 2 deletions src/ypspur-coordinator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down

0 comments on commit aaa9496

Please sign in to comment.