diff options
author | jsorg71 <jsorg71> | 2005-03-12 15:59:54 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2005-03-12 15:59:54 +0000 |
commit | 013c11499584361d6743588dd63db258c4f93848 (patch) | |
tree | 3b46d9ba4357ab2bef3bb10b9d8820cc58536a90 | |
parent | ed041b7983e2fa0a06c9242e9738a097d6834fdc (diff) | |
download | xrdp-proprietary-013c11499584361d6743588dd63db258c4f93848.tar.gz xrdp-proprietary-013c11499584361d6743588dd63db258c4f93848.zip |
deamon shutdown
-rw-r--r-- | xrdp/xrdp.c | 54 | ||||
-rw-r--r-- | xrdp/xrdp_listen.c | 1 |
2 files changed, 25 insertions, 30 deletions
diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index bff20372..511c4a80 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -23,45 +23,39 @@ #include "xrdp.h" static struct xrdp_listen* g_listen = 0; +static int g_threadid = 0; /* main threadid */ /*****************************************************************************/ -/* i can't get stupid in_val to work, hum using global var for now */ -THREAD_RV THREAD_CC xrdp_listen_run(void* in_val) +void shutdown(int sig) { - DEBUG(("listener started\n\r")); - xrdp_listen_main_loop(g_listen); - DEBUG(("listener done\n\r")); - return 0; -} + struct xrdp_listen* listen; -#define CLEAN_CLOSE + if (g_get_threadid() != g_threadid) + { + return; + } + g_printf("shutting down\n\r"); + g_printf("signal %d threadid %d\n\r", sig, g_get_threadid()); + listen = g_listen; + g_listen = 0; + if (listen != 0) + { + g_set_term(1); + g_sleep(1000); + xrdp_listen_delete(listen); + g_exit_system(); + } +} /*****************************************************************************/ int main(int argc, char** argv) { - int rv; - g_init_system(); - rv = 0; + g_threadid = g_get_threadid(); g_listen = xrdp_listen_create(); -#ifdef CLEAN_CLOSE - if (g_thread_create(xrdp_listen_run, 0) == 0) - { - g_getchar(); - g_set_term(1); - while (g_listen->status > 0) - { - g_sleep(100); - } - } - else - { - rv = 1; - } -#else + g_signal(2, shutdown); + g_signal(9, shutdown); + g_signal(15, shutdown); xrdp_listen_main_loop(g_listen); -#endif - xrdp_listen_delete(g_listen); - g_exit_system(); - return rv; + return 0; } diff --git a/xrdp/xrdp_listen.c b/xrdp/xrdp_listen.c index 6b965ecd..fb11be73 100644 --- a/xrdp/xrdp_listen.c +++ b/xrdp/xrdp_listen.c @@ -144,6 +144,7 @@ int xrdp_listen_main_loop(struct xrdp_listen* self) { g_printf("bind error in xrdp_listen_main_loop\n\r"); g_tcp_close(self->sck); + self->status = -1; return 1; } error = g_tcp_listen(self->sck); |