-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add windows crash_dump support & sys split (#713)
* add windows crash_dump support & sys split * fix: replace WRITE_PIPE_FD with HIGH_PRIORIT_FD in unix get_high_writer
- Loading branch information
Showing
6 changed files
with
273 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vscode/ | ||
dev.sh | ||
target/ |
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
name = "plugins" | ||
version = "0.1.0" | ||
authors = ["zhanglei.sec <[email protected]>"] | ||
edition = "2018" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[features] | ||
|
@@ -23,9 +23,24 @@ serde_json = "1" | |
protobuf-codegen-pure = "2.3" | ||
|
||
[dependencies.windows] | ||
version = "0.48.0" | ||
version = "0.58.0" | ||
features = [ | ||
"Win32_System_Diagnostics_ToolHelp", | ||
"Win32_Foundation", | ||
"Win32_Security", | ||
"Win32_Storage_FileSystem", | ||
"Win32_System_Console", | ||
"Win32_System_Services", | ||
"Win32_System_Kernel", | ||
"Win32_System_JobObjects", | ||
"Win32_System_Memory", | ||
"Win32_System_Threading", | ||
"Win32_System_Diagnostics", | ||
"Win32_System_Diagnostics_ToolHelp", | ||
"Win32_System_Diagnostics_Debug_Extensions", | ||
] | ||
|
||
|
||
# Library dependencies (Windows) | ||
[target.'cfg(target_os = "windows")'.dependencies] | ||
anyhow = "1.0" | ||
zip = "2.2" |
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,9 @@ | ||
#[cfg(target_family = "windows")] | ||
pub mod windows; | ||
#[cfg(target_family = "windows")] | ||
pub use windows::*; | ||
|
||
#[cfg(target_family = "unix")] | ||
pub mod unix; | ||
#[cfg(target_family = "unix")] | ||
pub use unix::*; |
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,61 @@ | ||
use std::os::unix::prelude::FromRawFd; | ||
|
||
#[cfg(feature = "debug")] | ||
const READ_PIPE_FD: i32 = 0; | ||
#[cfg(not(feature = "debug"))] | ||
const READ_PIPE_FD: i32 = 3; | ||
#[cfg(feature = "debug")] | ||
const WRITE_PIPE_FD: i32 = 1; | ||
#[cfg(not(feature = "debug"))] | ||
const WRITE_PIPE_FD: i32 = 4; | ||
const HIGH_PRIORIT_FD: i32 = 5; | ||
|
||
use std::{ | ||
fs::File, | ||
io::{BufReader, BufWriter}, | ||
sync::Arc, | ||
}; | ||
|
||
use parking_lot::Mutex; | ||
|
||
pub fn get_writer() -> Arc<Mutex<BufWriter<File>>> { | ||
Arc::new(Mutex::new(BufWriter::with_capacity(512 * 1024, unsafe { | ||
File::from_raw_fd(WRITE_PIPE_FD) | ||
}))) | ||
} | ||
|
||
pub fn get_high_writer() -> Arc<Mutex<BufWriter<File>>> { | ||
Arc::new(Mutex::new(BufWriter::with_capacity(512 * 1024, unsafe { | ||
File::from_raw_fd(HIGH_PRIORIT_FD) | ||
}))) | ||
} | ||
|
||
pub fn get_reader() -> Arc<Mutex<BufReader<File>>> { | ||
Arc::new(Mutex::new(BufReader::with_capacity(512 * 1024, unsafe { | ||
File::from_raw_fd(READ_PIPE_FD) | ||
}))) | ||
} | ||
|
||
extern "C" fn signal_handler(signal: i32) { | ||
eprintln!("catched signal {:?}, wait 3 seconds and exit", signal); | ||
unsafe { | ||
libc::sleep(3); | ||
libc::close(WRITE_PIPE_FD); | ||
libc::close(READ_PIPE_FD); | ||
if libc::fcntl(HIGH_PRIORIT_FD, libc::F_GETFD) != -1 | ||
|| std::io::Error::last_os_error().kind() != std::io::ErrorKind::InvalidInput | ||
{ | ||
libc::close(READ_PIPE_FD); | ||
} | ||
} | ||
} | ||
|
||
pub fn ignore_terminate() { | ||
unsafe { | ||
libc::signal(libc::SIGINT, libc::SIG_IGN); | ||
libc::signal(libc::SIGUSR1, libc::SIG_IGN); | ||
libc::signal(libc::SIGTERM, signal_handler as _); | ||
} | ||
} | ||
|
||
pub fn regist_exception_handler() {} |
Oops, something went wrong.