summaryrefslogtreecommitdiff
path: root/mysql-test/lib/My/SafeProcess
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-03-06 11:15:55 +0100
committerSergei Golubchik <serg@mariadb.org>2015-03-06 11:15:55 +0100
commit12d87c3ba52e5f79a4345cea4aaa0afc90411057 (patch)
treebbae2ac5057cb417e0afbf7d3c37187aedd47661 /mysql-test/lib/My/SafeProcess
parent206b111b114be9eccbecaac5f3060c2ecd6b575c (diff)
downloadmariadb-git-12d87c3ba52e5f79a4345cea4aaa0afc90411057.tar.gz
MDEV-7659 buildbot may leave stale mysqld
safe_process puts its children (mysqld, in this case) into a separate process group, to be able to kill it all at once. buildslave kills mtr's process group when it loses connection to the master. result? buildslave kills mtr and safe_process, but leaves stale mysqld processes in their own process groups. fix: put safe_process itself into a separate process group, then buildslave won't kill it and safe_process will kill mysqld'd and itself when it will notice that the parent mtr no longer exists.
Diffstat (limited to 'mysql-test/lib/My/SafeProcess')
-rw-r--r--mysql-test/lib/My/SafeProcess/safe_process.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/mysql-test/lib/My/SafeProcess/safe_process.cc b/mysql-test/lib/My/SafeProcess/safe_process.cc
index d6110f5f8c8..feb3eb4df66 100644
--- a/mysql-test/lib/My/SafeProcess/safe_process.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process.cc
@@ -125,7 +125,7 @@ extern "C" void handle_abort(int sig)
message("Got signal %d, child_pid: %d, sending ABRT", sig, child_pid);
if (child_pid > 0) {
- kill (-child_pid, SIGABRT); // Don't wait for it to terminate
+ kill(-child_pid, SIGABRT); // Don't wait for it to terminate
}
}
@@ -226,6 +226,18 @@ int main(int argc, char* const argv[] )
sleep(1);
}
+ /*
+ Child: Make this process it's own process group to be able to kill
+ it and any its children that hasn't changed a group themselves)
+
+ Parent: Detach from the parent's process group, so that killing a parent
+ group wouldn't kill us (if we're killed, there's no one to kill our child
+ processes that run in their own process group). There's a loop below
+ that monitors the parent, it's enough.
+ */
+ setpgid(0, 0);
+
+
if (child_pid == 0)
{
close(pfd[0]); // Close unused read end
@@ -236,10 +248,6 @@ int main(int argc, char* const argv[] )
signal(SIGHUP, SIG_DFL);
signal(SIGCHLD, SIG_DFL);
- // Make this process it's own process group to be able to kill
- // it and any childs(that hasn't changed group themself)
- setpgid(0, 0);
-
if (nocore)
{
struct rlimit corelim = { 0, 0 };