Browse Source

Merge branch 'openssl' of https://github.com/PurpleI2P/i2pd into openssl

pull/1771/head
orignal 2 years ago
parent
commit
63d7cffefe
  1. 60
      daemon/UnixDaemon.cpp
  2. 16
      libi2pd/Config.cpp

60
daemon/UnixDaemon.cpp

@ -55,15 +55,15 @@ void handle_signal(int sig)
case SIGPIPE: case SIGPIPE:
LogPrint(eLogInfo, "SIGPIPE received"); LogPrint(eLogInfo, "SIGPIPE received");
break; break;
case SIGTSTP: case SIGTSTP:
LogPrint(eLogInfo, "Daemon: Got SIGTSTP, disconnecting from network..."); LogPrint(eLogInfo, "Daemon: Got SIGTSTP, disconnecting from network...");
i2p::transport::transports.SetOnline(false); i2p::transport::transports.SetOnline(false);
break; break;
case SIGCONT: case SIGCONT:
LogPrint(eLogInfo, "Daemon: Got SIGCONT, restoring connection to network..."); LogPrint(eLogInfo, "Daemon: Got SIGCONT, restoring connection to network...");
i2p::transport::transports.SetOnline(true); i2p::transport::transports.SetOnline(true);
break; break;
} }
} }
namespace i2p namespace i2p
@ -180,27 +180,27 @@ namespace i2p
} }
gracefulShutdownInterval = 0; // not specified gracefulShutdownInterval = 0; // not specified
// handle signal TSTP // handle signal TSTP
bool handleTSTP; i2p::config::GetOption("unix.handle_sigtstp", handleTSTP); bool handleTSTP; i2p::config::GetOption("unix.handle_sigtstp", handleTSTP);
// Signal handler // Signal handler
struct sigaction sa; struct sigaction sa;
sa.sa_handler = handle_signal; sa.sa_handler = handle_signal;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART; sa.sa_flags = SA_RESTART;
sigaction(SIGHUP, &sa, 0); sigaction(SIGHUP, &sa, 0);
sigaction(SIGUSR1, &sa, 0); sigaction(SIGUSR1, &sa, 0);
sigaction(SIGABRT, &sa, 0); sigaction(SIGABRT, &sa, 0);
sigaction(SIGTERM, &sa, 0); sigaction(SIGTERM, &sa, 0);
sigaction(SIGINT, &sa, 0); sigaction(SIGINT, &sa, 0);
sigaction(SIGPIPE, &sa, 0); sigaction(SIGPIPE, &sa, 0);
if (handleTSTP) if (handleTSTP)
{ {
sigaction(SIGTSTP, &sa, 0); sigaction(SIGTSTP, &sa, 0);
sigaction(SIGCONT, &sa, 0); sigaction(SIGCONT, &sa, 0);
} }
return Daemon_Singleton::start(); return Daemon_Singleton::start();
} }
bool DaemonLinux::stop() bool DaemonLinux::stop()

16
libi2pd/Config.cpp

@ -312,18 +312,12 @@ namespace config {
; ;
#ifdef __linux__ #ifdef __linux__
options_description unix_specific("UNIX-specific options"); options_description unix_specific("UNIX-specific options");
unix_specific.add_options() unix_specific.add_options()
("unix.handle_sigtstp", bool_switch()->default_value(false), ("unix.handle_sigtstp", bool_switch()->default_value(false), "Handle SIGTSTP and SIGCONT signals (default: disabled)")
"Switch to offline mode if received signal TSTP (SIGTSTP)" ;
"(you can send it by pressing CTRL+Z in terminal or with"
" help commapnd kill and others, a.e pkill, if i2pd in "
"daemon mode). If you need to switch to online mode, send"
" signal CONT (SIGCONT)")
;
#endif #endif
m_OptionsDesc m_OptionsDesc
.add(general) .add(general)
.add(limits) .add(limits)
@ -348,7 +342,7 @@ namespace config {
.add(cpuext) .add(cpuext)
.add(meshnets) .add(meshnets)
#ifdef __linux__ #ifdef __linux__
.add(unix_specific) .add(unix_specific)
#endif #endif
; ;
} }

Loading…
Cancel
Save