-
Notifications
You must be signed in to change notification settings - Fork 667
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
wait: Support ptrace events for Linux #438
Conversation
ad62647
to
9993f08
Compare
This works on newer versions of Rust; not really sure how to cleanly do a cfg on a block in previous versions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I have an idea on how to get this working on non-nightly. I hope it works. :-)
@@ -184,6 +191,12 @@ fn decode(pid : pid_t, status: i32) -> WaitStatus { | |||
} else if status::signaled(status) { | |||
WaitStatus::Signaled(pid, status::term_signal(status), status::dumped_core(status)) | |||
} else if status::stopped(status) { | |||
#[cfg(any(target_os = "linux", target_os = "android"))] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know cfg
on blocks was possible, even if nightly only.
To do this on stable, I think your best approach is going to be adding an inner function like this:
// ...
} else if status::stopped(status) {
cfg_if! {
if #[cfg(any(target_os = "linux", target_os = "android"))] {
fn decode_stopped(status) -> WaitStatus {
// Linux code
}
} else {
fn decode_stopped(status) -> WaitStatus {
// Other platform code
}
}
}
decode_stopped(status)
} else {
// ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, should have pointed out where that comes from. We already have it in nix, so it's not a risk to use it.
Thanks @chaosagent! I'm going to try and get someone who's used these APIs to see if they make sense. Should be able to merge soon though. :-) |
I've found this implementation of this, which works pretty much the same, if that's of any help. Edit: screwed up markdown |
On a quick glance this seems OK to me. I can't remember if it's possible that non-signal event still has ptrace information. Anyway, that's better than my old solution! |
@chaosagent I'm really sorry for the delay on this PR. I'm going to assume that nothing has changed since November in terms of correctness. @homu r+ |
📌 Commit e6bfbbb has been approved by |
wait: Support ptrace events for Linux Adds new WaitStatus value `PtraceEvent`. Implementation of #273 that only affects Linux/Android.
☀️ Test successful - status |
changelog: Add note for ptrace events (#438)
Adds new WaitStatus value
PtraceEvent
. Implementation of #273 that only affects Linux/Android.