diff options
author | ilsimo <ilsimo> | 2006-07-13 20:15:21 +0000 |
---|---|---|
committer | ilsimo <ilsimo> | 2006-07-13 20:15:21 +0000 |
commit | fda836169ea105f8a7ccc7632500eac6839467c5 (patch) | |
tree | 379a37845247e279ef39e5fe6f4d65ca398ffb04 /sesman/sig.c | |
parent | 20e26f1ccd91c48a833425915a5413bf543796a1 (diff) | |
download | xrdp-proprietary-fda836169ea105f8a7ccc7632500eac6839467c5.tar.gz xrdp-proprietary-fda836169ea105f8a7ccc7632500eac6839467c5.zip |
making sesman multithread
Diffstat (limited to 'sesman/sig.c')
-rw-r--r-- | sesman/sig.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/sesman/sig.c b/sesman/sig.c index 940254c7..fc702bb6 100644 --- a/sesman/sig.c +++ b/sesman/sig.c @@ -27,6 +27,8 @@ #include "sesman.h" +#include "signal.h" + extern int g_sck; extern int g_pid; extern struct config_sesman g_cfg; @@ -73,3 +75,78 @@ sig_sesman_reload_cfg(int sig) log_message(LOG_LEVEL_INFO, "configuration reloaded"); } + +/******************************************************************************/ +void DEFAULT_CC +sig_sesman_session_end(int sig) +{ + int pid; + + if (g_getpid() != g_pid) + { + return; + } + pid = g_waitchild(); + if (pid > 0) + { + session_kill(pid); + } +} + +/******************************************************************************/ +void* DEFAULT_CC +sig_handler_thread(void* arg) +{ + int recv_signal; + sigset_t sigmask; + sigset_t oldmask; + sigset_t waitmask; + + /* mask signals to be able to wait for them... */ + sigfillset(&sigmask); + /* it is a good idea not to block SIGILL SIGSEGV */ + /* SIGFPE -- see sigaction(2) NOTES */ + pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask); + + /* building the signal wait mask... */ + sigemptyset(&waitmask); + sigaddset(&waitmask, SIGHUP); + sigaddset(&waitmask, SIGCHLD); + sigaddset(&waitmask, SIGTERM); +// sigaddset(&waitmask, SIGFPE); +// sigaddset(&waitmask, SIGILL); +// sigaddset(&waitmask, SIGSEGV); + + do + { + LOG_DBG("calling sigwait()",0); + sigwait(&waitmask, &recv_signal); + + switch (recv_signal) + { + case SIGHUP: + //reload cfg + LOG_DBG("sesman received SIGHUP",0); + //return 0; + break; + case SIGCHLD: + /* a session died */ + LOG_DBG("sesman received SIGCHLD",0); + sig_sesman_session_end(SIGCHLD); + break; + /*case SIGKILL; + /* we die * / + LOG_DBG("sesman received SIGKILL",0); + sig_sesman_shutdown(recv_signal); + break;*/ + case SIGTERM: + /* we die */ + LOG_DBG("sesman received SIGTERM",0); + sig_sesman_shutdown(recv_signal); + break; + } + } while (1); + + return 0; +} + |