From dd63693c4ae6059d9263576c82c8bc067ad3ad17 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 2 Nov 2016 13:45:45 -0600 Subject: [PATCH] Fix close in ptyd --- programs/orbutils | 2 +- schemes/orbital | 2 +- schemes/ptyd/src/main.rs | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/programs/orbutils b/programs/orbutils index 6f44e69..3ad66c8 160000 --- a/programs/orbutils +++ b/programs/orbutils @@ -1 +1 @@ -Subproject commit 6f44e698efdaaf308aa9f50892d8ca0a72d210aa +Subproject commit 3ad66c8a8e2dc11dbc50995b0e7cbf05391347e4 diff --git a/schemes/orbital b/schemes/orbital index daa786a..2c366e9 160000 --- a/schemes/orbital +++ b/schemes/orbital @@ -1 +1 @@ -Subproject commit daa786a4ea5b932296bff47ecdf81b4c3b715454 +Subproject commit 2c366e9bca7ca97096a77c7c3e355eeacb6db963 diff --git a/schemes/ptyd/src/main.rs b/schemes/ptyd/src/main.rs index d1f549d..4d4c649 100644 --- a/schemes/ptyd/src/main.rs +++ b/schemes/ptyd/src/main.rs @@ -53,6 +53,7 @@ impl SchemeMut for PtyScheme { } fn dup(&mut self, id: usize, _buf: &[u8]) -> Result { + /* TODO CLOEXEC - Master cannot be cloned let master_opt = self.ptys.0.get(&id).map(|pipe| pipe.clone()); if let Some(pipe) = master_opt { let pipe_id = self.next_id; @@ -60,6 +61,7 @@ impl SchemeMut for PtyScheme { self.ptys.0.insert(pipe_id, pipe); return Ok(pipe_id); } + */ let slave_opt = self.ptys.1.get(&id).map(|pipe| pipe.clone()); if let Some(pipe) = slave_opt { @@ -330,6 +332,17 @@ fn main(){ c: syscall::flag::EVENT_READ, d: data.len() }).expect("pty: failed to write event"); + } else if Rc::weak_count(&master.read) == 0 { + socket.write(&Packet { + id: 0, + pid: 0, + uid: 0, + gid: 0, + a: syscall::number::SYS_FEVENT, + b: *id, + c: syscall::flag::EVENT_READ, + d: 0 + }).expect("pty: failed to write event"); } }