When checking the status from waitpid on a kill -STOP <child_pid> WIFSIGNALED returns true #472
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently in WIFSIGNALED rust is doing:
(status & 0x7f) + 1
where status is i32
As defined in /usr/include/x86_64-linux-gnu/bits/waitstatus.h
#define __WIFSIGNALED(status)
(((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
Here is an example of the issue:
http://paste2.org/fXc8BxJ0
Run it, and it'll print the child pid then:
kill -STOP <child_pid>
Expect:
Stopped by signal print statement
Results:
Killed by signal print statement
Using the i32, it wont overflow leaving you with 128 returning true, using the waitstatus define you'll end up with -64 (since it shifts 1 right) which would return false. Though the C version shifts right once not really sure why but theres most likely a reason somewhere.
For the fix, just cast to i8 (signed char pretty much) as the C version is doing.
RUNNING ALL TESTS
PASSED 7356 tests