diff options
author | jsorg71 <jsorg71> | 2009-04-20 04:31:24 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2009-04-20 04:31:24 +0000 |
commit | c6b9952fa2ca89613e021ad8f64c6718b3442997 (patch) | |
tree | a2aefe06b1e69b8cd1ded5b6225d9c84b25a711f /sesman/sessvc | |
parent | da9934395772c727968e3a67eed13231bc9ec607 (diff) | |
download | xrdp-proprietary-c6b9952fa2ca89613e021ad8f64c6718b3442997.tar.gz xrdp-proprietary-c6b9952fa2ca89613e021ad8f64c6718b3442997.zip |
work on chansrv
Diffstat (limited to 'sesman/sessvc')
-rw-r--r-- | sesman/sessvc/sessvc.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/sesman/sessvc/sessvc.c b/sesman/sessvc/sessvc.c index 3d24070e..079a4b79 100644 --- a/sesman/sessvc/sessvc.c +++ b/sesman/sessvc/sessvc.c @@ -14,7 +14,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. xrdp: A Remote Desktop Protocol server. - Copyright (C) Jay Sorg 2005-2008 + Copyright (C) Jay Sorg 2005-2009 */ /** @@ -25,43 +25,53 @@ * */ +#if defined(HAVE_CONFIG_H) +#include "config_ac.h" +#endif +#include "file_loc.h" #include "os_calls.h" #include "arch.h" -#include "log.h" - -#include <sys/types.h> -#include <errno.h> - -pid_t wm_pid; -pid_t x_pid; - -void DEFAULT_CC -signal_handler(int sig) -{ - g_sigterm(x_pid); - g_sigterm(wm_pid); - g_exit(0); -} /******************************************************************************/ int DEFAULT_CC main(int argc, char** argv) { - int ret=0; + int ret; + int chansrv_pid; + int wm_pid; + int x_pid; + char exe_path[262]; + if (argc < 3) + { + g_writeln("xrdp-sessvc: exiting, not enough params"); + return 1; + } x_pid = g_atoi(argv[1]); wm_pid = g_atoi(argv[2]); - - g_printf("\n[sessvc] Setting signal handler\n"); - g_signal(9, signal_handler); /* SIGKILL */ - g_signal(15, signal_handler); /* SIGTERM */ - g_signal(17, signal_handler); /* SIGCHLD */ - - g_printf("\n[sessvc] Waiting for X (pid %d) and WM (pid %d)\n", x_pid, wm_pid); - + g_writeln("xrdp-sessvc: waiting for X (pid %d) and WM (pid %d)", + x_pid, wm_pid); + /* run xrdp-chansrv as a seperate process */ + chansrv_pid = g_fork(); + if (chansrv_pid == -1) + { + g_writeln("xrdp-sessvc: fork error"); + return 1; + } + else if (chansrv_pid == 0) /* child */ + { + g_snprintf(exe_path, 261, "%s/xrdp-chansrv", XRDP_SBIN_PATH); + g_execvp(exe_path, 0); + /* should not get here */ + return 1; + } + /* wait for window manager to get done */ ret = g_waitpid(wm_pid); + /* kill X server */ g_sigterm(x_pid); - - g_printf("\n[sessvc] WM is dead (waitpid said %d, errno is %d). exiting...\n", ret, errno); + /* kill channel server */ + g_sigterm(chansrv_pid); + g_writeln("xrdp-sessvc: WM is dead (waitpid said %d, errno is %d) " + "exiting...", ret, g_get_errno()); return 0; } |