Skip to content

Commit

Permalink
Merge pull request #1936 from ipuustin/close-channel-receivers
Browse files Browse the repository at this point in the history
main_process: close the channel receivers.
  • Loading branch information
utam0k authored May 17, 2023
2 parents 668a31c + ae49a0a commit 271640b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions crates/libcontainer/src/process/container_main_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ pub fn container_main_process(container_args: &ContainerArgs) -> Result<(Pid, bo
err
})?;

let (inter_sender, _) = inter_chan;
let (init_sender, _) = init_chan;
let (inter_sender, inter_receiver) = inter_chan;
let (init_sender, init_receiver) = init_chan;

// If creating a rootless container, the intermediate process will ask
// the main process to set up uid and gid mapping, once the intermediate
Expand Down Expand Up @@ -135,6 +135,23 @@ pub fn container_main_process(container_args: &ContainerArgs) -> Result<(Pid, bo

tracing::debug!("init pid is {:?}", init_pid);

// Close the receiver ends to avoid leaking file descriptors.

inter_receiver.close().map_err(|err| {
tracing::error!("failed to close intermediate process receiver: {}", err);
err
})?;

init_receiver.close().map_err(|err| {
tracing::error!("failed to close init process receiver: {}", err);
err
})?;

main_receiver.close().map_err(|err| {
tracing::error!("failed to close main process receiver: {}", err);
err
})?;

// Before the main process returns, we want to make sure the intermediate
// process is exit and reaped. By this point, the intermediate process
// should already exited successfully. If intermediate process errors out,
Expand Down

0 comments on commit 271640b

Please sign in to comment.