Enable Win32_Security feature for CreateMutexW and clean up Windows warnings
Some checks are pending
Release & Packaging / Build Linux Packages (.tar.gz, .deb, .rpm, .AppImage) (push) Waiting to run
Release & Packaging / Build Windows Binaries (.exe) (push) Waiting to run
Release & Packaging / Publish GitHub Release (push) Blocked by required conditions
Some checks are pending
Release & Packaging / Build Linux Packages (.tar.gz, .deb, .rpm, .AppImage) (push) Waiting to run
Release & Packaging / Build Windows Binaries (.exe) (push) Waiting to run
Release & Packaging / Publish GitHub Release (push) Blocked by required conditions
This commit is contained in:
parent
1e8f440acb
commit
3d5496d4ab
3 changed files with 14 additions and 15 deletions
|
|
@ -46,6 +46,7 @@ windows = { version = "0.58.0", features = [
|
|||
"Win32_Graphics_Dxgi",
|
||||
"Win32_Graphics_Dxgi_Common",
|
||||
"Win32_Graphics_Gdi",
|
||||
"Win32_Security",
|
||||
"Win32_System_Com",
|
||||
"Win32_UI_WindowsAndMessaging",
|
||||
"Win32_System_Threading",
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||
println!("Daemon listening on TCP IPC: 127.0.0.1:42069");
|
||||
l
|
||||
}
|
||||
Err(e) => {
|
||||
Err(_e) => {
|
||||
if scythe::ipc::query_status().is_ok() {
|
||||
println!("Another instance of scythe-daemon is already running. Exiting cleanly.");
|
||||
return Ok(());
|
||||
|
|
|
|||
|
|
@ -144,21 +144,19 @@ fn check_and_toggle_overlay() -> bool {
|
|||
}
|
||||
|
||||
if let Ok(content) = std::fs::read_to_string(&pid_path) {
|
||||
#[cfg(unix)]
|
||||
if let Ok(pid) = content.trim().parse::<i32>() {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let exists = unsafe { libc::kill(pid, 0) == 0 };
|
||||
if exists && pid != std::process::id() as i32 {
|
||||
let proc_cmd = format!("/proc/{}/cmdline", pid);
|
||||
let is_scythe = std::fs::read_to_string(&proc_cmd)
|
||||
.map(|cmd| cmd.contains("scythe") || cmd.contains("vrec"))
|
||||
.unwrap_or(false);
|
||||
if is_scythe {
|
||||
// Overlay already open: toggle it closed instantly!
|
||||
unsafe { libc::kill(pid, libc::SIGTERM) };
|
||||
let _ = std::fs::remove_file(&pid_path);
|
||||
return true;
|
||||
}
|
||||
let exists = unsafe { libc::kill(pid, 0) == 0 };
|
||||
if exists && pid != std::process::id() as i32 {
|
||||
let proc_cmd = format!("/proc/{}/cmdline", pid);
|
||||
let is_scythe = std::fs::read_to_string(&proc_cmd)
|
||||
.map(|cmd| cmd.contains("scythe") || cmd.contains("vrec"))
|
||||
.unwrap_or(false);
|
||||
if is_scythe {
|
||||
// Overlay already open: toggle it closed instantly!
|
||||
unsafe { libc::kill(pid, libc::SIGTERM) };
|
||||
let _ = std::fs::remove_file(&pid_path);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue