Skip to content

Commit 558f8e5

Browse files
authored
Merge pull request #595 from KCSesh/apiserver-fd-bug
apiserver: fix file descriptor leak in exec
2 parents cbcfb20 + 6906800 commit 558f8e5

File tree

1 file changed

+7
-0
lines changed
  • sources/api/apiserver/src/server/exec

1 file changed

+7
-0
lines changed

sources/api/apiserver/src/server/exec/child.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,13 @@ impl ChildHandles {
241241
}
242242
}
243243

244+
impl Drop for ChildHandles {
245+
/// Ensures the RawFd is properly closed when ChildHandles is dropped.
246+
fn drop(&mut self) {
247+
let _ = close(self.pty_fd);
248+
}
249+
}
250+
244251
/// ChildFds sets up read and write file descriptors for a Command (before it's spawned) based on
245252
/// whether the user requested a TTY.
246253
struct ChildFds {

0 commit comments

Comments
 (0)