diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2021-12-12 20:15:47 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2021-12-12 20:15:47 +0100 |
commit | 18c8a22486819ab88e552b39eee8add0894afed9 (patch) | |
tree | 133b21c32da49338da78318477c02d80d96bb6d8 | |
parent | a1e1ae7ffac99ed89a04aceb9d9c0de83b1c1d88 (diff) | |
download | vtcol-18c8a22486819ab88e552b39eee8add0894afed9.tar.gz |
lib: close console fd on drop
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -998,6 +998,20 @@ impl Console } } +impl Drop for Console +{ + fn drop(&mut self) + { + if unsafe { libc::close(self.0) } == -1 { + eprintln!( + "Console: error closing fd {}: {}", + self.0, + Error::last_os_error() + ); + } + } +} + impl AsRawFd for Console { fn as_raw_fd(&self) -> RawFd { self.0 } |