summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-12-12 20:15:47 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-12-12 20:15:47 +0100
commit18c8a22486819ab88e552b39eee8add0894afed9 (patch)
tree133b21c32da49338da78318477c02d80d96bb6d8 /src
parenta1e1ae7ffac99ed89a04aceb9d9c0de83b1c1d88 (diff)
downloadvtcol-18c8a22486819ab88e552b39eee8add0894afed9.tar.gz
lib: close console fd on drop
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4ff9bba..6a932d8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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 }