Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5dbb4c96
Commit
5dbb4c96
authored
Mar 10, 2008
by
msvensson@pilot.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ignore all common signals
Just retry OpenEvent a couple of times with a "yield" in between
parent
34605cc1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
18 deletions
+12
-18
mysql-test/lib/My/SafeProcess/safe_kill_win.cc
mysql-test/lib/My/SafeProcess/safe_kill_win.cc
+12
-18
No files found.
mysql-test/lib/My/SafeProcess/safe_kill_win.cc
View file @
5dbb4c96
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <windows.h>
#include <windows.h>
#include <stdio.h>
#include <stdio.h>
#include <signal.h>
int
main
(
int
argc
,
const
char
**
argv
)
int
main
(
int
argc
,
const
char
**
argv
)
{
{
...
@@ -30,6 +31,10 @@ int main(int argc, const char** argv )
...
@@ -30,6 +31,10 @@ int main(int argc, const char** argv )
HANDLE
shutdown_event
;
HANDLE
shutdown_event
;
char
safe_process_name
[
32
]
=
{
0
};
char
safe_process_name
[
32
]
=
{
0
};
int
retry_open_event
=
100
;
int
retry_open_event
=
100
;
/* Ignore any signals */
signal
(
SIGINT
,
SIG_IGN
);
signal
(
SIGBREAK
,
SIG_IGN
);
signal
(
SIGTERM
,
SIG_IGN
);
if
(
argc
!=
2
)
{
if
(
argc
!=
2
)
{
fprintf
(
stderr
,
"safe_kill <pid>
\n
"
);
fprintf
(
stderr
,
"safe_kill <pid>
\n
"
);
...
@@ -37,31 +42,20 @@ int main(int argc, const char** argv )
...
@@ -37,31 +42,20 @@ int main(int argc, const char** argv )
}
}
pid
=
atoi
(
argv
[
1
]);
pid
=
atoi
(
argv
[
1
]);
_snprintf
(
safe_process_name
,
sizeof
(
safe_process_name
),
"safe_process[%d]"
,
pid
);
_snprintf
(
safe_process_name
,
sizeof
(
safe_process_name
),
"safe_process[%d]"
,
pid
);
/* Open the event to signal */
/* Open the event to signal */
while
((
shutdown_event
=
while
((
shutdown_event
=
OpenEvent
(
EVENT_MODIFY_STATE
,
FALSE
,
safe_process_name
))
==
NULL
)
OpenEvent
(
EVENT_MODIFY_STATE
,
FALSE
,
safe_process_name
))
==
NULL
)
{
{
fprintf
(
stderr
,
"Failed to open shutdown_event '%s', error: %d
\n
"
,
safe_process_name
,
GetLastError
());
/* Just check to see if pid exists */
HANDLE
pid_handle
=
OpenProcess
(
SYNCHRONIZE
,
FALSE
,
pid
);
if
(
pid_handle
==
NULL
)
fprintf
(
stderr
,
"Could not open process with pid %d, error: %d
\n
"
,
pid
);
else
CloseHandle
(
pid_handle
);
if
(
retry_open_event
--
)
if
(
retry_open_event
--
)
{
Sleep
(
0
);
/* yield */
fprintf
(
stderr
,
"retrying...
\n
"
);
Sleep
(
100
);
/* In milli seconds */
}
else
else
{
{
fprintf
(
stderr
,
"No more retries, exiting"
);
fprintf
(
stderr
,
"Failed to open shutdown_event '%s', error: %d
\n
"
,
exit
(
1
);
safe_process_name
,
GetLastError
());
exit
(
3
);
}
}
}
}
...
@@ -70,7 +64,7 @@ int main(int argc, const char** argv )
...
@@ -70,7 +64,7 @@ int main(int argc, const char** argv )
fprintf
(
stderr
,
"Failed to signal shutdown_event '%s', error: %d
\n
"
,
fprintf
(
stderr
,
"Failed to signal shutdown_event '%s', error: %d
\n
"
,
safe_process_name
,
GetLastError
());
safe_process_name
,
GetLastError
());
CloseHandle
(
shutdown_event
);
CloseHandle
(
shutdown_event
);
exit
(
1
);
exit
(
4
);
}
}
CloseHandle
(
shutdown_event
);
CloseHandle
(
shutdown_event
);
exit
(
0
);
exit
(
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment