Squash some errors; only attempt wire communication when necessary
This commit is contained in:
parent
90c9d9b784
commit
2f6c583f3a
|
@ -295,8 +295,7 @@ pub fn parse_format(fp: &mut (impl io::Read + io::Seek)) -> anyhow::Result<(File
|
||||||
// was moved between compilation and ingestion. but how...
|
// was moved between compilation and ingestion. but how...
|
||||||
let metadata = match fs::metadata(&filename) {
|
let metadata = match fs::metadata(&filename) {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) if e.kind() == io::ErrorKind::NotFound => return Ok(None),
|
Err(_) => return Ok(None),
|
||||||
Err(e) => return Err(e)?,
|
|
||||||
};
|
};
|
||||||
if !metadata.is_file() {
|
if !metadata.is_file() {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
|
|
|
@ -421,8 +421,17 @@ impl TracerClient {
|
||||||
ptrace::setoptions(root_child.into(), ptrace_opts)?;
|
ptrace::setoptions(root_child.into(), ptrace_opts)?;
|
||||||
// restart child
|
// restart child
|
||||||
ptrace::syscall(nix::unistd::Pid::from(root_child.into()), None)?;
|
ptrace::syscall(nix::unistd::Pid::from(root_child.into()), None)?;
|
||||||
loop {
|
let mut continuing = true;
|
||||||
let status = waitpid(None, Some(WaitPidFlag::__WALL))?;
|
while continuing {
|
||||||
|
let status = {
|
||||||
|
let status = waitpid(None, Some(WaitPidFlag::__WALL));
|
||||||
|
if status.is_err_and(|e| e == nix::errno::Errno::ECHILD) {
|
||||||
|
continuing = false;
|
||||||
|
Ok(WaitStatus::StillAlive)
|
||||||
|
} else {
|
||||||
|
status
|
||||||
|
}
|
||||||
|
}?;
|
||||||
// log::trace!("waitpid: {:?}", status);
|
// log::trace!("waitpid: {:?}", status);
|
||||||
let signal = match status {
|
let signal = match status {
|
||||||
WaitStatus::Stopped(pid, sig) => {
|
WaitStatus::Stopped(pid, sig) => {
|
||||||
|
@ -467,9 +476,6 @@ impl TracerClient {
|
||||||
self.log_root(pid, Event::Exit { code });
|
self.log_root(pid, Event::Exit { code });
|
||||||
self.store.get_current_mut(pid).unwrap().status =
|
self.store.get_current_mut(pid).unwrap().status =
|
||||||
ProcessStatus::Exited(code);
|
ProcessStatus::Exited(code);
|
||||||
if pid == root_child {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
WaitStatus::PtraceEvent(pid, sig, evt) => {
|
WaitStatus::PtraceEvent(pid, sig, evt) => {
|
||||||
|
@ -559,7 +565,7 @@ impl TracerClient {
|
||||||
_ => None
|
_ => None
|
||||||
};
|
};
|
||||||
|
|
||||||
if !self.pending_files.is_empty() || !self.pending_events.is_empty() {
|
if !self.pending_files.is_empty() || !continuing {
|
||||||
let mut events = vec![];
|
let mut events = vec![];
|
||||||
let mut files = BTreeSet::new();
|
let mut files = BTreeSet::new();
|
||||||
std::mem::swap(&mut events, &mut self.pending_events);
|
std::mem::swap(&mut events, &mut self.pending_events);
|
||||||
|
|
Loading…
Reference in New Issue