summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sesman/sesman.c35
-rw-r--r--sesman/sesman.h4
-rw-r--r--sesman/sig.c2
3 files changed, 35 insertions, 6 deletions
diff --git a/sesman/sesman.c b/sesman/sesman.c
index f1648116..3ee2ce55 100644
--- a/sesman/sesman.c
+++ b/sesman/sesman.c
@@ -29,8 +29,6 @@
#include <string.h>
#include <errno.h>
-#define SESMAN_PID_FILE "/usr/local/xrdp/sesman.pid"
-
int g_sck;
int g_pid;
unsigned char g_fixedkey[8] = { 23, 82, 107, 6, 35, 78, 88, 7 };
@@ -62,7 +60,6 @@ cterm(int s)
}
/**
- *
*
* Starts sesman main loop
*
@@ -215,11 +212,25 @@ main(int argc, char** argv)
else if ( (2==argc) && ( (0 == g_strncasecmp(argv[1],"--help",7)) || (0 == g_strncasecmp(argv[1],"-h",2)) ) )
{
/* help screen */
- g_printf("...\n");
+ g_printf("sesman - xrdp session manager\n\n");
+ g_printf("usage: sesman [command]\n\n");
+ g_printf("command can be one of the following:\n");
+ g_printf("-n, --nodaemon starts sesman in foregroun\n");
+ g_printf("-k, --kill kills running sesman\n");
+ g_printf("-h, --help shows this help\n");
+ g_printf("if no command is specified, sesman is started in background");
+ g_exit(0);
}
else if ( (2==argc) && ( (0 == g_strncasecmp(argv[1],"--kill",11)) || (0 == g_strncasecmp(argv[1],"-k",11)) ) )
{
/* killing running sesman */
+ /* check if sesman is running */
+ if (!g_file_exist(SESMAN_PID_FILE))
+ {
+ g_printf("sesman is not running (pid file not found)\n");
+ g_exit(1);
+ }
+
fd = g_file_open(SESMAN_PID_FILE);
if (-1 == fd)
@@ -242,11 +253,23 @@ main(int argc, char** argv)
else
{
/* there's something strange on the command line */
- g_printf("sesman - xrdp session manager\n");
- g_printf("usage: sesman [ --nodaemon | --kill ]\n");
+ g_printf("sesman - xrdp session manager\n\n");
+ g_printf("error: invalid command line\n");
+ g_printf("usage: sesman [ --nodaemon | --kill | --help ]\n");
g_exit(1);
}
+
+
+ if (g_file_exist(SESMAN_PID_FILE))
+ {
+ g_printf("sesman is already running.\n");
+ g_printf("if it's not running, try removing ");
+ g_printf(SESMAN_PID_FILE);
+ g_printf("\n");
+ g_exit(1);
+ }
+
/* reading config */
if (0 != config_read(&g_cfg))
{
diff --git a/sesman/sesman.h b/sesman/sesman.h
index d61e004c..ebdec77d 100644
--- a/sesman/sesman.h
+++ b/sesman/sesman.h
@@ -34,4 +34,8 @@
#include "sig.h"
#include "session.h"
+#ifndef SESMAN_PID_FILE
+ #define SESMAN_PID_FILE "./sesman.pid"
+#endif
+
#endif
diff --git a/sesman/sig.c b/sesman/sig.c
index 18492568..140a48f9 100644
--- a/sesman/sig.c
+++ b/sesman/sig.c
@@ -49,6 +49,8 @@ sig_sesman_shutdown(int sig)
LOG_DBG(" - getting signal %d pid %d", sig, g_getpid());
g_tcp_close(g_sck);
+
+ g_file_delete(SESMAN_PID_FILE);
}
/******************************************************************************/