summaryrefslogtreecommitdiff
path: root/server/util
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2009-05-05 13:36:17 +0200
committerSimo Sorce <ssorce@redhat.com>2009-05-08 10:11:11 -0400
commitb348e98e47d3ef287fed4d2e272bbf08540e0295 (patch)
tree64f63094d6c8e947c163fba0f69a62c290b554b6 /server/util
parent4146c660af61cca7f3c4bcd89d810de1d34bae0a (diff)
downloadsssd-b348e98e47d3ef287fed4d2e272bbf08540e0295.tar.gz
sssd-b348e98e47d3ef287fed4d2e272bbf08540e0295.tar.bz2
sssd-b348e98e47d3ef287fed4d2e272bbf08540e0295.zip
Use tevent for shutdown signals, remove old pidfile, make sssd single-instance.
Use tevent signal handling facilities for handlong SIGTERM and SIGINT in the monitor. Remove pidfile on SIGTERM and SIGINT. Make sssd single-instance by checking if we suceeded in signaling the process in the pidfile.
Diffstat (limited to 'server/util')
-rw-r--r--server/util/server.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/server/util/server.c b/server/util/server.c
index b2d6a3ce..a2402922 100644
--- a/server/util/server.c
+++ b/server/util/server.c
@@ -27,6 +27,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
#include "util/util.h"
#include "ldb.h"
#include "confdb/confdb.h"
@@ -110,11 +111,18 @@ int pidfile(const char *path, const char *name)
if (pid != 0) {
errno = 0;
ret = kill(pid, 0);
- if (ret != 0 && errno != ESRCH) {
+ /* succeeded in signaling the process -> another sssd process */
+ if (ret == 0) {
close(fd);
free(file);
return EEXIST;
}
+ if (ret != 0 && errno != ESRCH) {
+ err = errno;
+ close(fd);
+ free(file);
+ return err;
+ }
}
}