Skip to content

Commit 6906800

Browse files
committed
apiserver: fix file descriptor leak in exec
The ChildHandles struct was not properly closing the file descriptor (pty_fd) when dropped. This caused a leak of one RawFd per apiclient exec command. Added a Drop implementation to ensure proper cleanup of the raw file descriptor. Signed-off-by: Kyle Sessions <[email protected]>
1 parent 9668a6a commit 6906800

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)