Skip to content

Commit

Permalink
Ensure rofiles-fuse gets SIGTERM if we exit
Browse files Browse the repository at this point in the history
I've seen us leak fuse processes on the build side; I think
this happens when we get SIGINT (ctrl-c).  Ensure that in this
case the fuse process gets SIGTERM, so it can gracefully unmount
itself.
  • Loading branch information
cgwalters committed Oct 24, 2023
1 parent 1733241 commit 770822d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions rust/src/bwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use fn_error_context::context;
use ostree_ext::{gio, glib};
use std::num::NonZeroUsize;
use std::os::unix::io::AsRawFd;
use std::os::unix::process::CommandExt;
use std::path::Path;
use std::process::Command;

Expand Down Expand Up @@ -83,12 +84,20 @@ impl RoFilesMount {
let tempdir = tempfile::Builder::new()
.prefix("rpmostree-rofiles-fuse")
.tempdir()?;
let status = std::process::Command::new("rofiles-fuse")
.arg("--copyup")
let mut c = std::process::Command::new("rofiles-fuse");
c.arg("--copyup")
.arg(path)
.arg(tempdir.path())
.cwd_dir(rootfs.try_clone()?)
.status()?;
.cwd_dir(rootfs.try_clone()?);
unsafe {
c.pre_exec(|| {
rustix::process::set_parent_process_death_signal(Some(
rustix::process::Signal::Term,
))
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
});
}
let status = c.status()?;
if !status.success() {
return Err(anyhow::anyhow!("{}", status));
}
Expand Down

0 comments on commit 770822d

Please sign in to comment.