-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
env: add program signal messages #3290
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
Conversation
Cool! For testing, is it possible to just check whether the output includes that error message? |
src/uu/env/src/env.rs
Outdated
let signal_code = exit.signal().unwrap(); | ||
println!( | ||
"{}{}", | ||
unsafe { |
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.
Maybe
pub fn signal_name_by_value(signal_value: usize) -> Option<&'static str> { |
There was a problem hiding this comment.
Choose a 8000 reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, thanks! When I was looking into how to test, I came across it and I'm using that now.
However, I'm still not sure how to test, considering what I did before was run a program that raised a signal - I don't know how to raise a signal straight from the command line.
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.
kill
will send a signal to a process.
8eadf1f
to
287cf82
Compare
Sorry to pester with messages and requests - the test case I've tried creating doesn't seem to be catching any output. I've added a new commit (that I'll clean up more once it's working) that emulates what I know has worked typing into the terminal. $ ~/repo/coreutils/target/debug/env sleep 100
<in another terminal>
$ ps -e | grep sleep
$ kill -s SEGV <pid>
<back to original terminal>
"env sleep" terminated by signal SIGSEGV (core dumped)
$ $?
139 <the error number specified in env.rs, 128 + 11>
|
I guess you saw the errors ?
|
935518e
to
feab2aa
Compare
I think I've just fixed that error - there's a problem with the MinRustV. I use a function to determine if I should print The problem with the test remains - it doesn't work, and I'm not sure how to fix up this test to actually test the signal messages, as even killing GNU's coreutil's I've separated the test from the |
Thanks! It looks like that function is only stabilized in 1.58, so I think it's best to avoid it for now if possible. I think it's fine to leave out the test for this if it's really that hard to test. |
feab2aa
to
c64a061
Compare
c64a061
to
298f73f
Compare
Looks good! Thank you! |
Addresses #3188.
libc
as a dependency in order to convert a signal number into a name. If there's reservations about this, I could instead have output liketerminated by signal 11
. I try to describe my logic for thinking this is safe in a comment.