agent: Fix fd leaks in execute_hook

Fixes: #480

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2020-08-03 10:03:51 +08:00
parent ec84a94a61
commit 06834931a6

View File

@ -1495,6 +1495,11 @@ fn execute_hook(logger: &Logger, h: &Hook, st: &OCIState) -> Result<()> {
// state.push_str("\n");
let (rfd, wfd) = unistd::pipe2(OFlag::O_CLOEXEC)?;
defer!({
let _ = unistd::close(rfd);
let _ = unistd::close(wfd);
});
match unistd::fork()? {
ForkResult::Parent { child: _ch } => {
let buf = read_sync(rfd)?;