-
Notifications
You must be signed in to change notification settings - Fork 3
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
Migrate to our own Signal type #365
Conversation
Important Auto Review SkippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
24b6a14
to
efe75d3
Compare
This is part of #353. This commit prepares for the transition to our own Signal type by defining the type and implementing some basic operations.
This commit adds a new variant Signal::Number(c_int) to allow specifying any signal by its raw signal number. This will make the parser for the trap built-in condition operand much simpler.
This commit replaces the SigSet type with an array of Signal in the System trait. This change is necessary because the SigSet type is specific to the nix crate, and the System trait should not depend on specific types from external crates. This commit also updates the implementations of the System trait to reflect this change. SelectSystem::wait_mask is now an optional Vec of Signal, and virtual Process now uses a BTreeSet of Signal instead of SigSet.
This change makes `rt_range` return an empty range when the real system does not support real-time signals. This simplifies the code that uses `rt_range` because the caller does not need to handle the `None` case.
} | ||
|
||
/// Creates an iterator that yields all signals available in the real system. | ||
pub fn all_signals() -> impl DoubleEndedIterator<Item = Signal2> { |
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.
warning: function `all_signals` is never used
--> yash-env/src/system/real/signal.rs:411:8
|
411 | pub fn all_signals() -> impl DoubleEndedIterator {
| ^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
The conversion from ProcessState to ExitStatus is now done by the System trait as it depends on the system implementation. This commit removes the TryFrom implementation and replaces it with a call to System::exit_status_for_process_state.
The conversion should be done by `SystemEx::exit_status_for_signal`.
This PR is quite messed up. I'm thinking of starting over with a more organized plan. 🤔 I'm thinking of defining Unresolved questions:
|
Closing in favor of #367 |
This is part of #353.
This PR also adds support for real-time signals on some platforms.
Signal
definitionSignal
from and to raw numbers inSystem
SigSet
fromSystem
Move conversion from signal number toCondition
out ofimpl std::str::FromStr for Condition
ProcessState
and nix'sWaitStatus
impl TryFrom<ProcessState> for ExitStatus
withSystemEx::exit_status_for_process_state
impl From<Signal> for ExitStatus
withSystemEx::exit_status_for_signal
impl TryFrom<ExitStatus> for Signal
Signal
Additional todo:
ProcessState
so we don't have to unwrap the result ofSystemEx::exit_status_for_process_state
ProcessResult::{Exited,Signaled,Stopped}
which is guaranteed to have a corresponding exit status.Subshell::start_and_wait
(and maybe some other functions) should return the new enum. → Add ProcessResult #366