Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ endif()
option(ENABLE_CONFIGURATION "Enable server configuration" ON)
set(THREAD_COUNT 5 CACHE STRING "Number of threads accepting new sessions and handling requests")
set(DEFAULT_HOST_KEY "/etc/ssh/ssh_host_rsa_key" CACHE STRING "Default server host key (used only if configuration is disabled)")
set(DISABLE_RESTART_SIGNALS 0 CACHE STRING "Set this to 1 to treat SIGHUP and SIGUSR1 as termination signals instead of restart signals")

# set prefix for the PID file
if (NOT PIDFILE_PREFIX)
Expand Down
7 changes: 7 additions & 0 deletions server/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
# define NP2SRV_THREAD_COUNT @THREAD_COUNT@
#endif

/** @brief If set to 0, SIGHUP and SIGUSR1 will attempt to restart the server's main thread.
* If set to 1, SIGHUP and SIGUSR1 are treated as termination signals (like SIGTERM)
*/
#ifndef NP2SRV_DISABLE_RESTART_SIGNALS
# define NP2SRV_DISABLE_RESTART_SIGNALS @DISABLE_RESTART_SIGNALS@
#endif

/** @brief availability of pthread_rwlockattr_setkind_np()
*/
#cmakedefine HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP 1
Expand Down
12 changes: 7 additions & 5 deletions server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ signal_handler(int sig)
static int quit = 0;

switch (sig) {
case SIGHUP:
case SIGUSR1:
#if NP2SRV_DISABLE_RESTART_SIGNALS == 0
/* restart the process */
control = LOOP_RESTART;
break;
#endif
case SIGINT:
case SIGTERM:
case SIGQUIT:
Expand All @@ -217,11 +224,6 @@ signal_handler(int sig)
}
control = LOOP_STOP;
break;
case SIGHUP:
case SIGUSR1:
/* restart the process */
control = LOOP_RESTART;
break;
#ifdef DEBUG
case SIGSEGV:
depth = backtrace(stack_buf, STACK_DEPTH);
Expand Down