Skip to content
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

Cmd pdeathsig #943

Merged
merged 2 commits into from
Dec 10, 2024
Merged

Cmd pdeathsig #943

merged 2 commits into from
Dec 10, 2024

Conversation

cgwalters
Copy link
Collaborator

@cgwalters cgwalters commented Dec 6, 2024

utils: Add a lifecycle_bind helper for Command

In almost all children we fork, we want the child to reliably
exit if we do (e.g. especially if we panic). The Linux
PR_SET_PDEATHSIG is just great for this.

Signed-off-by: Colin Walters walters@verbum.org


utils: Use run helper for editor

I just happened to glance at this code, this gives us stderr
in the error, etc.

Signed-off-by: Colin Walters walters@verbum.org


@github-actions github-actions bot added the area/install Issues related to `bootc install` label Dec 6, 2024
In almost all children we fork, we want the child to reliably
exit if we do (e.g. especially if we panic). The Linux
PR_SET_PDEATHSIG is just great for this.

Signed-off-by: Colin Walters <walters@verbum.org>
I just happened to glance at this code, this gives us stderr
in the error, etc.

Signed-off-by: Colin Walters <walters@verbum.org>
Copy link
Contributor

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

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

This could go in as-is, but see comments/questions below (mostly superficial, or for the sake of my own curiosity)...

lib/src/install.rs Show resolved Hide resolved
utils/src/command.rs Show resolved Hide resolved
utils/src/command.rs Show resolved Hide resolved
@@ -84,6 +88,19 @@ impl CommandRunExt for Command {
self.status()?.check_status(stderr)
}

#[allow(unsafe_code)]
fn lifecycle_bind(&mut self) -> &mut Self {
// SAFETY: This API is safe to call in a forked child.
Copy link
Contributor

Choose a reason for hiding this comment

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

A docs reference would be good (even if it's just to say that this is implemented with prctl and point to the list in signal-safety manpage)...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, the rustix docs for this function do link directly to the prctl man page right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think while we could have more safety explanations in cases like this, what we have here is actually better than some of the other (few) unsafe cases and if we were to try to raise the bar we'd need to a bit more

lib/src/utils.rs Show resolved Hide resolved
@cgwalters cgwalters merged commit f34e5dd into containers:main Dec 10, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/install Issues related to `bootc install`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants