From 95d0bceae7def5b94abe301118a8474cbbb2e3ec Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Mon, 18 Nov 2019 13:34:20 +0000 Subject: [PATCH] MCOL-3559 Stop postConfigure if mysqld is running It is possible that a user will already have a MariaDB Server running before executing postConfigure. Exit early in this scenario. --- oamapps/postConfigure/postConfigure.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index 981870dff..17fb4867d 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -539,6 +539,18 @@ int main(int argc, char* argv[]) exit (1); } + char buf[512]; + FILE *cmd_pipe = popen("pidof -s mysqld", "r"); + fgets(buf, 512, cmd_pipe); + pid_t pid = strtoul(buf, NULL, 10); + pclose(cmd_pipe); + + if (pid) + { + cout << "MariaDB Server is currently running on PID " << pid << ". Cannot run postConfigure whilst this is running. Exiting.." << endl; + exit (1); + } + //check Config saved files if ( !checkSaveConfigFile()) {