Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- python/sanlock.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/sanlock.c b/python/sanlock.c index cefe3d4..e32fab3 100644 --- a/python/sanlock.c +++ b/python/sanlock.c @@ -288,7 +288,7 @@ py_add_lockspace(PyObject *self __unused, PyObject *args, PyObject *keywds) memset(&ls, 0, sizeof(struct sanlk_lockspace));
/* parse python tuple */ - if (!PyArg_ParseTupleAndKeywords(args, keywds, "sks|ki", kwlist, + if (!PyArg_ParseTupleAndKeywords(args, keywds, "sks|kIi", kwlist, &lockspace, &ls.host_id, &path, &ls.host_id_disk.offset, &iotimeout, &async)) { return NULL;
Signed-off-by: Federico Simoncelli fsimonce@redhat.com --- src/main.c | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/main.c b/src/main.c index af12299..2213e31 100644 --- a/src/main.c +++ b/src/main.c @@ -1241,8 +1241,9 @@ static int setup_listener(void) return -1; }
-static void sigterm_handler(int sig GNUC_UNUSED) +static void sigterm_handler(int sig, siginfo_t *info, void *ctx) { + log_info("signal %i received from pid %u exiting", sig, info->si_pid); external_shutdown = 1; }
@@ -1428,6 +1429,25 @@ static void setup_groups(void) free(pgroup); }
+static void setup_signals(void) +{ + struct sigaction act; + int rv, i, sig_list[] = { SIGHUP, SIGINT, SIGTERM, 0 }; + + memset(&act, 0, sizeof(act)); + + act.sa_flags = SA_SIGINFO; + act.sa_sigaction = sigterm_handler; + + for (i = 0; sig_list[i] != 0; i++) { + rv = sigaction(sig_list[i], &act, NULL); + if (rv < 0) { + log_error("cannot set the signal handler for: %i", sig_list[i]); + exit(EXIT_FAILURE); + } + } +} + /* * first pipe for daemon to send requests to helper; they are not acknowledged * and the daemon does not get any result back for the requests. @@ -1553,7 +1573,6 @@ static void helper_dead(int ci GNUC_UNUSED)
static int do_daemon(void) { - struct sigaction act; int fd, rv;
/* TODO: copy comprehensive daemonization method from libvirtd */ @@ -1584,12 +1603,7 @@ static int do_daemon(void) goto out_logging; strcpy(client[helper_ci].owner_name, "helper");
- memset(&act, 0, sizeof(act)); - act.sa_handler = sigterm_handler; - rv = sigaction(SIGTERM, &act, NULL); - if (rv < 0) - return rv; - + setup_signals(); setup_logging();
fd = lockfile(SANLK_RUN_DIR, SANLK_LOCKFILE_NAME, com.uid, com.gid);
sanlock-devel@lists.fedorahosted.org