Репозитории ALT
5.1: | 3.6.4-alt2.rel3.2 |
4.1: | 3.6.4-alt2.rel3 |
4.0: | 3.6.1-alt1 |
3.0: | |
+backports: | 3.0-alt0.M30.4 |
Группа :: Система/Серверы
Пакет: ss5
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: ss5-signalhandling.patch
Скачать
Скачать
diff -ruN ss5-3.6.1.orig/include/SS5Utils.h ss5-3.6.1/include/SS5Utils.h
--- ss5-3.6.1.orig/include/SS5Utils.h 2006-05-08 18:05:45 +0400
+++ ss5-3.6.1/include/SS5Utils.h 2006-10-06 18:34:47 +0400
@@ -93,5 +93,15 @@
unsigned long int dsti,
unsigned long int srci
);
+
+#ifdef LINUX
+void
+ S5SigHandler( int sig
+);
+
+void
+ S5SetSigHandler( int sig
+);
+#endif
#endif
diff -ruN ss5-3.6.1.orig/src/SS5Main.c ss5-3.6.1/src/SS5Main.c
--- ss5-3.6.1.orig/src/SS5Main.c 2006-10-06 18:40:22 +0400
+++ ss5-3.6.1/src/SS5Main.c 2006-10-06 18:38:16 +0400
@@ -54,7 +54,12 @@
strcpy(S5PidFileName,"/var/run/ss5/ss5.pid");
S5PidFile=NULL;
-
+
+#ifdef LINUX
+ struct sigaction sa;
+ sigset_t ss;
+#endif
+
/*
* Initialize server static data to default values
*/
@@ -263,17 +268,17 @@
/*
* Ignore signal when child die
- */
+
if( SS5SocksOpt.PreforkProcesses == 1 ) {
actionChild.sa_flags = SA_RESTART;
actionChild.sa_handler = SIG_IGN;
sigaction(SIGCHLD,&actionChild,NULL);
}
-
+ */
/*
* Set HUNGUP handler to reload function
* and ignore SIGPIPE
- */
+
actionHungup.sa_flags = SA_RESTART;
actionHungup.sa_handler = S5ReloadConfig;
sigaction(SIGHUP,&actionHungup,NULL);
@@ -281,6 +286,13 @@
actionPipe.sa_flags = SA_RESTART;
actionPipe.sa_handler = SIG_IGN;
sigaction(SIGPIPE,&actionPipe,NULL);
+ */
+
+ S5SetSigHandler(SIGTERM);
+ S5SetSigHandler(SIGINT);
+ S5SetSigHandler(SIGHUP);
+ S5SetSigHandler(SIGPIPE);
+ S5SetSigHandler(SIGCHLD);
totalChildren = SS5SocksOpt.PreforkProcesses;
diff -ruN ss5-3.6.1.orig/src/SS5Utils.c ss5-3.6.1/src/SS5Utils.c
--- ss5-3.6.1.orig/src/SS5Utils.c 2006-10-06 18:40:22 +0400
+++ ss5-3.6.1/src/SS5Utils.c 2006-10-06 18:39:01 +0400
@@ -1188,6 +1188,44 @@
exit(-1);
}
+#ifdef LINUX
+void S5SetSigHandler( int sig )
+{
+ struct sigaction sa;
+ sigset_t ss;
+ sigemptyset(&ss);
+ sigaddset(&ss,sig);
+ if(sigprocmask(SIG_UNBLOCK,&ss,NULL)==(-1)) {
+ fprintf(stderr,"Can't unblock signal %d: %s",sig,strerror(errno));
+ S5ServerClose(EXIT);
+ }
+ memset(&sa,0,sizeof(sa));
+ sa.sa_flags = SA_RESTART;
+ if (sig == SIGHUP)
+ sa.sa_handler=S5ReloadConfig;
+ else if (sig == SIGCHLD)
+ {
+ if( SS5SocksOpt.PreforkProcesses == 1 )
+ signal(SIGCHLD,SIG_IGN);
+ }
+ else if (sig == SIGPIPE)
+ sa.sa_handler=SIG_IGN;
+ else
+ sa.sa_handler=S5SigHandler;
+ if(sigaction(sig,&sa,NULL)==(-1)) {
+ fprintf(stderr,"Can't set signal handler on %d: %s",sig,strerror(errno));
+ S5ServerClose(EXIT);
+ }
+}
+
+void S5SigHandler( int sig )
+{
+ pid_t pid;
+ pid=waitpid(-1,NULL,WNOHANG);
+ S5ServerClose(EXIT);
+}
+#endif
+
void S5ReloadConfig( int sig )
{
if( sig == SIGHUP )