-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Looks like a fair bit of unix-specific code has gotten tangled up in the main files Have separated the unix specific process logic into the unix.rs module Created a wrapper for the Signal type since its not available on non unix platforms, non unix platforms just handle it as a uppercase string (No special handling at this stage, but could be implemented at a later stage if we make our own signal enum that maps to the unix enum) Added a new WindowsProcess type for windows processes, Wired up the code to collect and kill in separate places Added process name lookup for windows processes (To match the other impls) if a process has a bad name or fails to obtain its name None is used instead Docker container killing is working, however it doesn't work properly if you don't explicitly specify the container mode (I think its trying to kill the wrong one causing it to fail?) Made the type for a killable into an enum as its possible values are constant? Renamed the killport_tests.rs to killport_unix_tests.rs and gated it to unix only since its using unix specific features, Windows tests will need to be added Added a build and release target for windows to the github workflows
- Loading branch information
1 parent
4997258
commit 0624cb5
Showing
14 changed files
with
300 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//! Wrapper around signals for platforms that they are not supported on | ||
|
||
use std::{fmt::Display, str::FromStr}; | ||
|
||
#[cfg(unix)] | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub struct KillportSignal(pub nix::sys::signal::Signal); | ||
|
||
/// On a platform where we don't have the proper signals enum | ||
#[cfg(not(unix))] | ||
#[derive(Debug, Clone)] | ||
pub struct KillportSignal(pub String); | ||
|
||
impl Display for KillportSignal { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
Display::fmt(&self.0, f) | ||
} | ||
} | ||
|
||
impl FromStr for KillportSignal { | ||
type Err = std::io::Error; | ||
|
||
fn from_str(value: &str) -> Result<Self, Self::Err> { | ||
#[cfg(unix)] | ||
{ | ||
let signal = nix::sys::signal::Signal::from_str(value)?; | ||
Ok(KillportSignal(signal)) | ||
} | ||
|
||
#[cfg(not(unix))] | ||
{ | ||
Ok(KillportSignal(value.to_string())) | ||
} | ||
} | ||
} |
Oops, something went wrong.