2022-06-22 14:09:59 -04:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
2023-11-09 09:50:58 -05:00
|
|
|
use color_eyre::eyre::{Result, WrapErr};
|
|
|
|
|
use rustix::io::FdFlags;
|
2022-09-19 13:47:44 -04:00
|
|
|
use std::os::unix::prelude::*;
|
2022-07-20 08:05:01 -07:00
|
|
|
|
2022-10-23 19:48:00 -04:00
|
|
|
pub(crate) fn mark_as_not_cloexec(file: &impl AsFd) -> Result<()> {
|
2023-11-09 09:50:58 -05:00
|
|
|
let flags = rustix::io::fcntl_getfd(file).wrap_err("failed to get GETFD value of stream")?;
|
|
|
|
|
rustix::io::fcntl_setfd(file, flags.difference(FdFlags::CLOEXEC))
|
|
|
|
|
.wrap_err("failed to unset CLOEXEC on file")
|
2022-07-20 08:05:01 -07:00
|
|
|
}
|