summaryrefslogtreecommitdiff
path: root/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
diff options
context:
space:
mode:
authorunknown <knielsen@knielsen-hq.org>2009-11-30 22:37:27 +0100
committerunknown <knielsen@knielsen-hq.org>2009-11-30 22:37:27 +0100
commitdb260b19e3edb9e153abf784711a3ae13e40db4a (patch)
tree4a9d9e50072d36ee917a570f8bf83a0117e971db /mysql-test/lib/My/SafeProcess/safe_kill_win.cc
parent0df8279c468235f4feaf9eb25aa2beb5032ee1dc (diff)
parent4a458290441937661136c73afa61393a6634f7b0 (diff)
downloadmariadb-git-db260b19e3edb9e153abf784711a3ae13e40db4a.tar.gz
Merge MySQL 5.1.41 into MariaDB trunk, including a number of after-merge fixes.
Also merge charset patch.
Diffstat (limited to 'mysql-test/lib/My/SafeProcess/safe_kill_win.cc')
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_kill_win.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
index c6256fd92e1..963a02c8099 100755
--- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
@@ -30,7 +30,7 @@ int main(int argc, const char** argv )
DWORD pid= -1;
HANDLE shutdown_event;
char safe_process_name[32]= {0};
- int retry_open_event= 100;
+ int retry_open_event= 2;
/* Ignore any signals */
signal(SIGINT, SIG_IGN);
signal(SIGBREAK, SIG_IGN);
@@ -51,15 +51,31 @@ int main(int argc, const char** argv )
{
/*
Check if the process is alive, otherwise there is really
- no idea to retry the open of the event
+ no sense to retry the open of the event
*/
HANDLE process;
- if ((process= OpenProcess(SYNCHRONIZE, FALSE, pid)) == NULL)
+ DWORD exit_code;
+ process= OpenProcess(SYNCHRONIZE| PROCESS_QUERY_INFORMATION, FALSE, pid);
+ if (!process)
{
- fprintf(stderr, "Could not open event or process %d, error: %d\n",
- pid, GetLastError());
- exit(3);
+ /* Already died */
+ exit(1);
+ }
+
+ if (!GetExitCodeProcess(process,&exit_code))
+ {
+ fprintf(stderr, "GetExitCodeProcess failed, pid= %d, err= %d\n",
+ pid, GetLastError());
+ exit(1);
}
+
+ if (exit_code != STILL_ACTIVE)
+ {
+ /* Already died */
+ CloseHandle(process);
+ exit(2);
+ }
+
CloseHandle(process);
if (retry_open_event--)