Add server start/stop timeout to force kill server if it gets stuck
This commit is contained in:
@@ -1,11 +1,27 @@
|
||||
/// Force kill process on Unix by sending SIGKILL.
|
||||
///
|
||||
/// This is unsafe because the PID isn't checked.
|
||||
pub unsafe fn force_kill(pid: u32) -> bool {
|
||||
debug!(target: "lazymc", "Sending SIGKILL signal to {} to kill server", pid);
|
||||
let result = libc::kill(pid as i32, libc::SIGKILL);
|
||||
|
||||
if result != 0 {
|
||||
trace!(target: "lazymc", "SIGKILL failed: {}", result);
|
||||
}
|
||||
|
||||
result == 0
|
||||
}
|
||||
|
||||
/// Gracefully kill process on Unix by sending SIGTERM.
|
||||
///
|
||||
/// This is unsafe because the PID isn't checked.
|
||||
pub unsafe fn kill_gracefully(pid: u32) {
|
||||
pub unsafe fn kill_gracefully(pid: u32) -> bool {
|
||||
debug!(target: "lazymc", "Sending SIGTERM signal to {} to kill server", pid);
|
||||
let result = libc::kill(pid as i32, libc::SIGTERM);
|
||||
trace!(target: "lazymc", "SIGTERM result: {}", result);
|
||||
|
||||
// TODO: send sigterm to childs as well?
|
||||
// TODO: handle error if result != 0
|
||||
if result != 0 {
|
||||
trace!(target: "lazymc", "SIGTERM failed: {}", result);
|
||||
}
|
||||
|
||||
result == 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user