Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/bg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ impl Bg {
{
return Err(io::Error::last_os_error());
}
// openpty does not set close-on-exec, so without this every later child (claude, its
// tool shells, openers) would inherit both ends of this pty and keep them open
// SAFETY: fcntl on two descriptors openpty just returned; it only sets a flag.
unsafe {
libc::fcntl(m, libc::F_SETFD, libc::FD_CLOEXEC);
libc::fcntl(s, libc::F_SETFD, libc::FD_CLOEXEC);
}
// SAFETY: openpty succeeded, so `m` and `s` are open descriptors that nothing else owns;
// each OwnedFd takes over exactly one of them and closes it once.
let m = unsafe { OwnedFd::from_raw_fd(m) };
Expand Down
Loading