summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 }