Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat jvm attach result check #673

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions rasp/librasp/src/cpython.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,17 @@ pub fn pangolin_inject_file(pid: i32, file_path: &str) -> Result<bool> {
Ok(true)
} else if es_code == 255 {
let msg = format!(
"python attach exit code 255: {} {} {} {}",
es_code, pid, &stdout, &stderr
"python attach exit code 255: {} {} {}",
es_code, &stdout, &stderr
);
error!("{}", msg);
error!("pid: {}, {}", pid, msg);
Err(anyhow!("{}", msg))
} else {
let msg = format!(
"python attach exit code {} {} {} {}",
es_code, pid, &stdout, &stderr
"python attach exit code {} {} {}",
es_code, &stdout, &stderr
);
error!("{}", msg);
error!("pid: {}, {}", pid, msg);
Err(anyhow!("{}", msg))
}
}
Expand Down
26 changes: 17 additions & 9 deletions rasp/librasp/src/jvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn java_attach(pid: i32) -> Result<bool> {
let es_code = match es.code() {
Some(ec) => ec,
None => {
return Err(anyhow!("get status code failed: {}", pid));
return Err(anyhow!("get status code failed: {}, output: {}, err: {}", pid, out, err));
}
};
if es_code == 0 {
Expand All @@ -82,16 +82,24 @@ pub fn java_attach(pid: i32) -> Result<bool> {
Ok(_) => {
return Ok(true);
}
Err(e) => {
return Err(anyhow!(e.to_string()));
Err(_) => {
std::thread::sleep(Duration::from_millis(500));
match check_result(pid, "attach") {
Ok(_) => {
return Ok(true);
}
Err(e) => {
return Err(anyhow!(e.to_string()));
}
}
}
}
} else {
let msg = format!(
"jvm attach exit code {} {} {} {}",
es_code, pid, &out, &err
"jvm attach exit code {} {} {}",
es_code, &out, &err
);
error!("{}", msg);
error!("pid: {}, {}", pid, msg);
Err(anyhow!("{}", msg))
}
}
Expand Down Expand Up @@ -244,10 +252,10 @@ pub fn java_detach(pid: i32) -> Result<bool> {
}
} else {
let msg = format!(
"jvm detach exit code {} {} {} {}",
es_code, pid, &out, &err
"jvm detach exit code {} {} {}",
es_code, &out, &err
);
error!("{}", msg);
error!("pid: {}, {}", pid, msg);
Err(anyhow!("{}", msg))
}
}
Expand Down
Loading