Skip to content

Commit

Permalink
Send SIGCONT unconditionally (#110)
Browse files Browse the repository at this point in the history
* Send SIGCONT unconditionally

* Fix clippy 1.77 lints

* Add Gabriel to CODEOWNERS

* Oops
  • Loading branch information
Jake-Shadle authored Mar 21, 2024
1 parent 0bf4837 commit f13d7a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @Jake-Shadle
* @Jake-Shadle @gabrielesvelto
14 changes: 3 additions & 11 deletions src/linux/maps_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,7 @@ impl MappingInfo {

#[inline]
fn so_version(&self) -> Option<SoVersion> {
let Some(name) = self.name.as_deref() else {
return None;
};

SoVersion::parse(name)
SoVersion::parse(self.name.as_deref()?)
}

pub fn get_mapping_effective_path_name_and_version(
Expand Down Expand Up @@ -422,16 +418,12 @@ pub struct SoVersion {
impl SoVersion {
/// Attempts to retrieve the .so version of the elf path via its filename
fn parse(so_path: &OsStr) -> Option<Self> {
let Some(filename) = std::path::Path::new(so_path).file_name() else {
return None;
};
let filename = std::path::Path::new(so_path).file_name()?;

// Avoid an allocation unless the string contains non-utf8
let filename = filename.to_string_lossy();

let Some((_, version)) = filename.split_once(".so.") else {
return None;
};
let (_, version) = filename.split_once(".so.")?;

let mut sov = Self {
major: 0,
Expand Down
8 changes: 1 addition & 7 deletions src/linux/ptrace_dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct Thread {
#[derive(Debug)]
pub struct PtraceDumper {
pub pid: Pid,
process_stopped: bool,
threads_suspended: bool,
pub threads: Vec<Thread>,
pub auxv: HashMap<AuxvType, AuxvType>,
Expand Down Expand Up @@ -99,7 +98,6 @@ impl PtraceDumper {
pub fn new(pid: Pid, stop_timeout: Duration) -> Result<Self, InitError> {
let mut dumper = PtraceDumper {
pid,
process_stopped: false,
threads_suspended: false,
threads: Vec::new(),
auxv: HashMap::new(),
Expand Down Expand Up @@ -255,7 +253,6 @@ impl PtraceDumper {

loop {
if let Ok(ProcState::Stopped) = Stat::from_file(&proc_file)?.state() {
self.process_stopped = true;
return Ok(());
}

Expand All @@ -270,10 +267,7 @@ impl PtraceDumper {
///
/// Unlike `stop_process`, this function does not wait for the process to continue.
fn continue_process(&mut self) -> Result<(), ContinueProcessError> {
if self.process_stopped {
signal::kill(nix::unistd::Pid::from_raw(self.pid), Some(signal::SIGCONT))?;
}
self.process_stopped = false;
signal::kill(nix::unistd::Pid::from_raw(self.pid), Some(signal::SIGCONT))?;
Ok(())
}

Expand Down

0 comments on commit f13d7a2

Please sign in to comment.