Skip to content

Commit

Permalink
ignore partial error while attaching task
Browse files Browse the repository at this point in the history
  • Loading branch information
YangKeao committed Jan 15, 2021
1 parent b749e37 commit 2a41926
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mount_injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl MountInjectionGuard {
pub fn recover_mount(mut self) -> Result<()> {
let mount_point = self.original_path.clone();

retry(Fixed::from_millis(200).take(10), || {
retry(Fixed::from_millis(500).take(20), || {
if let Err(err) = umount(mount_point.as_path()) {
info!("umount returns error: {:?}", err);
return OperationResult::Retry(err);
Expand Down
14 changes: 10 additions & 4 deletions src/ptrace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,23 @@ impl PtraceManager {
match counter_ref.get_mut(&raw_pid) {
Some(count) => *count += 1,
None => {
info!("send SIGSTOP to process: {}", pid);
trace!("send SIGSTOP to process: {}", pid);
kill(pid, Signal::SIGSTOP)?;
info!("stop {} successfully", pid);
trace!("stop {} successfully", pid);

let process = procfs::process::Process::new(raw_pid)?;
for task in process.tasks()? {
if let Ok(task) = task {
let pid = Pid::from_raw(task.tid);

info!("attach task: {}", task.tid);
ptrace::attach(pid)?;
match ptrace::attach(pid) {
Err(nix::Error::Sys(nix::errno::Errno::ESRCH)) => {
info!("task {} doesn't exist, maybe has stopped", task.tid)
}
Err(err) => {return Err(err.into())}
_ => {}
}
info!("attach task: {} successfully", task.tid);

// TODO: check wait result
Expand Down Expand Up @@ -92,7 +98,7 @@ impl PtraceManager {
match ptrace::detach(Pid::from_raw(task.tid), None) {
Ok(()) => {}
Err(nix::Error::Sys(nix::errno::Errno::ESRCH)) => {
// ignore because the task could be newly created
info!("task {} doesn't exist, maybe has stopped", task.tid)
}
Err(err) => return Err(err.into()),
}
Expand Down

0 comments on commit 2a41926

Please sign in to comment.