aboutsummaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty/unix.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty_terminal/src/tty/unix.rs')
-rw-r--r--alacritty_terminal/src/tty/unix.rs42
1 files changed, 26 insertions, 16 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index 483333e7..a52f8329 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -246,6 +246,16 @@ pub fn new<C>(config: &Config<C>, size: &SizeInfo, window_id: Option<usize>) ->
}
}
+impl Drop for Pty {
+ fn drop(&mut self) {
+ // Make sure the PTY is terminated properly.
+ unsafe {
+ libc::kill(self.child.id() as i32, libc::SIGHUP);
+ }
+ let _ = self.child.wait();
+ }
+}
+
impl EventedReadWrite for Pty {
type Reader = File;
type Writer = File;
@@ -339,6 +349,22 @@ impl EventedPty for Pty {
}
}
+impl OnResize for Pty {
+ /// Resize the PTY.
+ ///
+ /// Tells the kernel that the window size changed with the new pixel
+ /// dimensions and line/column counts.
+ fn on_resize(&mut self, size: &SizeInfo) {
+ let win = size.to_winsize();
+
+ let res = unsafe { libc::ioctl(self.fd.as_raw_fd(), libc::TIOCSWINSZ, &win as *const _) };
+
+ if res < 0 {
+ die!("ioctl TIOCSWINSZ failed: {}", io::Error::last_os_error());
+ }
+ }
+}
+
/// Types that can produce a `libc::winsize`.
pub trait ToWinsize {
/// Get a `libc::winsize`.
@@ -356,22 +382,6 @@ impl<'a> ToWinsize for &'a SizeInfo {
}
}
-impl OnResize for Pty {
- /// Resize the PTY.
- ///
- /// Tells the kernel that the window size changed with the new pixel
- /// dimensions and line/column counts.
- fn on_resize(&mut self, size: &SizeInfo) {
- let win = size.to_winsize();
-
- let res = unsafe { libc::ioctl(self.fd.as_raw_fd(), libc::TIOCSWINSZ, &win as *const _) };
-
- if res < 0 {
- die!("ioctl TIOCSWINSZ failed: {}", io::Error::last_os_error());
- }
- }
-}
-
unsafe fn set_nonblocking(fd: c_int) {
use libc::{fcntl, F_GETFL, F_SETFL, O_NONBLOCK};