summaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-01-04 03:51:32 -0600
committerAlejandro Soto <alejandro@34project.org>2022-01-04 03:51:32 -0600
commit1c02eebc71a0ede4e75fea516920697850bbe030 (patch)
tree3a54355a5e34d5539fe413e0e3b17a8e9b832601 /src/util.rs
parentb5c8846482d5309fac92c7ab94d4f53690b201b4 (diff)
Implement unmount
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/util.rs b/src/util.rs
index c21442f..5da19c8 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -29,6 +29,12 @@ pub struct OutputChain<'a> {
pub struct OutputChainIter<'a>(Option<&'a OutputChain<'a>>);
+impl DumbFd {
+ pub fn take(&mut self) -> DumbFd {
+ DumbFd(std::mem::replace(&mut self.0, -1))
+ }
+}
+
impl IntoRawFd for DumbFd {
fn into_raw_fd(self) -> RawFd {
let fd = self.0;
@@ -39,7 +45,9 @@ impl IntoRawFd for DumbFd {
impl Drop for DumbFd {
fn drop(&mut self) {
- let _ = close(self.0);
+ if !self.0.is_negative() {
+ let _ = close(self.0);
+ }
}
}