wip: better handling of cloexec with reused fds for panel and notifications daemon
This commit is contained in:
parent
183fc329c1
commit
8bff06e9a7
4 changed files with 122 additions and 30 deletions
|
|
@ -17,3 +17,18 @@ pub(crate) fn mark_as_not_cloexec(file: &impl AsFd) -> Result<()> {
|
|||
.wrap_err("failed to set CLOEXEC on file")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn mark_as_cloexec(file: &impl AsFd) -> Result<()> {
|
||||
let raw_fd = file.as_fd().as_raw_fd();
|
||||
let fd_flags = fcntl::FdFlag::from_bits(
|
||||
fcntl::fcntl(raw_fd, fcntl::FcntlArg::F_GETFD)
|
||||
.wrap_err("failed to get GETFD value of stream")?,
|
||||
)
|
||||
.wrap_err("failed to get fd flags from file")?;
|
||||
fcntl::fcntl(
|
||||
raw_fd,
|
||||
fcntl::FcntlArg::F_SETFD(fd_flags.union(fcntl::FdFlag::FD_CLOEXEC)),
|
||||
)
|
||||
.wrap_err("failed to set CLOEXEC on file")?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue