From: Martin Schwenke Date: Fri, 7 Feb 2020 05:11:23 +0000 (+1100) Subject: ctdb-tools: When in test mode set process group in top-level ctdb tool X-Git-Tag: ldb-2.1.1~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39206fd327f1ea154a8936b99cba0bf9bf221484;p=thirdparty%2Fsamba.git ctdb-tools: When in test mode set process group in top-level ctdb tool If ctdbd hangs when shutting down in post-test clean-up then killing the process group can kill the test. When in test mode, create a process group but only in the top-level ctdb tool - the natgw and lvs helpers also run the ctdb tool. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index c157838018e..c464c91a4cf 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -6301,6 +6301,7 @@ int main(int argc, const char *argv[]) const char **extra_argv; int extra_argc; const struct ctdb_cmd *cmd; + const char *test_mode; int loglevel; bool ok; int ret = 0; @@ -6375,6 +6376,16 @@ int main(int argc, const char *argv[]) } debuglevel_set(loglevel); + /* Stop process group kill in alarm_handler() from killing tests */ + test_mode = getenv("CTDB_TEST_MODE"); + if (test_mode != NULL) { + const char *have_setpgid = getenv("CTDB_TOOL_SETPGID"); + if (have_setpgid == NULL) { + setpgid(0, 0); + setenv("CTDB_TOOL_SETPGID", "1", 1); + } + } + signal(SIGALRM, alarm_handler); alarm(options.maxruntime);