Add SIGSTOP and SIGCONT functions, fix some docs stuff

This commit is contained in:
[object Object]
2022-12-28 12:00:32 -08:00
parent c6f860f013
commit 716cd48eac
3 changed files with 36 additions and 8 deletions

View File

@@ -42,7 +42,7 @@ const SERVER_JOIN_GAME_TIMEOUT: Duration = Duration::from_secs(20);
///
/// Notchian servers are slow, we must wait a little before sending play packets, because the
/// server needs time to transition the client into this state.
/// See warning at: https://wiki.vg/Protocol#Login_Success
/// See warning at: <https://wiki.vg/Protocol#Login_Success>
const SERVER_WARMUP: Duration = Duration::from_secs(1);
/// Serve lobby service for given client connection.

View File

@@ -18,7 +18,7 @@ pub fn offline_player_uuid(username: &str) -> Uuid {
///
/// Static factory to retrieve a type 3 (name based) `Uuid` based on the specified byte array.
///
/// Ported from: https://git.io/J1b6A
/// Ported from: <https://git.io/J1b6A>
fn java_name_uuid_from_bytes(data: &[u8]) -> Uuid {
let mut hasher = Md5::new();
hasher.update(data);

View File

@@ -1,26 +1,54 @@
/// Force kill process on Unix by sending SIGKILL.
/// 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);
debug!(target: "lazymc", "Sending SIGKILL signal to {pid} to kill server");
let result = libc::kill(pid as i32, libc::SIGKILL);
if result != 0 {
trace!(target: "lazymc", "SIGKILL failed: {}", result);
trace!(target: "lazymc", "SIGKILL failed: {result}");
}
result == 0
}
/// Gracefully kill process on Unix by sending SIGTERM.
/// Gracefully kill process on Unix by sending `SIGTERM`.
///
/// This is unsafe because the PID isn't checked.
pub unsafe fn kill_gracefully(pid: u32) -> bool {
debug!(target: "lazymc", "Sending SIGTERM signal to {} to kill server", pid);
debug!(target: "lazymc", "Sending SIGTERM signal to {pid} to kill server");
let result = libc::kill(pid as i32, libc::SIGTERM);
if result != 0 {
warn!(target: "lazymc", "Sending SIGTERM signal to server failed: {}", result);
warn!(target: "lazymc", "Sending SIGTERM signal to server failed: {result}");
}
result == 0
}
/// Freeze process on Unix by sending `SIGSTOP`.
///
/// This is unsaft because the PIS isn't checked.
pub unsafe fn freeze(pid: u32) -> bool {
debug!(target: "lazymc", "Sending SIGSTOP signal to {pid} to kill server");
let result = libc::kill(pid as i32, libc::SIGSTOP);
if result != 0 {
warn!(target: "lazymc", "Sending SIGSTOP signal to server failed: {result}");
}
result == 0
}
/// Unfreeze process on Unix by sending `SIGCONT`.
///
/// This is unsaft because the PIS isn't checked.
pub unsafe fn unfreeze(pid: u32) -> bool {
debug!(target: "lazymc", "Sending SIGCONT signal to {pid} to unfreeze server");
let result = libc::kill(pid as i32, libc::SIGCONT);
if result != 0 {
warn!(target: "lazymc", "Sending SIGCONT signal to server failed: {result}");
}
result == 0