Skip to content
Merged
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
5 changes: 2 additions & 3 deletions rust/src/bwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ impl RoFilesMount {
.cwd_dir(rootfs.try_clone()?);
unsafe {
c.pre_exec(|| {
rustix::process::set_parent_process_death_signal(Some(
Ok(rustix::process::set_parent_process_death_signal(Some(
rustix::process::Signal::TERM,
))
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
))?)
Comment on lines +97 to +99

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this change correctly avoids allocation in the pre_exec closure, it can be written more idiomatically using .map_err(Into::into). This achieves the same non-allocating error conversion from rustix::io::Errno to std::io::Error in a more direct and arguably clearer way. This pattern is also used elsewhere in the codebase (see rust/src/cmdutils.rs:103).

                rustix::process::set_parent_process_death_signal(Some(
                    rustix::process::Signal::TERM,
                ))
                .map_err(Into::into)

Copy link
Contributor Author

@purplesyringa purplesyringa Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, and rust/src/extensions.rs:171, rust/src/countme/cookie.rs:148, rust/src/treefile.rs:4732, rust/src/treefile.rs:4749, and a ton of other locations use Ok(result?). I can't with these guys.

Though I guess it's a similar snippet. Not sure if that matters for consistency, I'll wait for a review.

});
}
c.run()?;
Expand Down