From d11e3db1db427cf8a2987e4ec5bb97288b808e2a Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 5 Jul 2013 02:10:44 -0400 Subject: refactor identifyTTY to match better how it will be used when integrated --- whosocket.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'whosocket.hs') diff --git a/whosocket.hs b/whosocket.hs index 420b707a..97912eff 100644 --- a/whosocket.hs +++ b/whosocket.hs @@ -41,8 +41,15 @@ whosocket addr_str port_str = do r <- getLocalPeerCred' addr -- putStrLn $ "r{"++show addr++"} = " ++ show r + us <- UTmp.users + let filterTTYs (_,tty,pid) = + if L.take 3 tty == "tty" + then Just (tty,pid) + else Nothing + tty_pids = mapMaybe filterTTYs us + tty <- maybe (return Nothing) - (uncurry identifyTTY) + (uncurry $ identifyTTY tty_pids) r putStrLn $ "uid = " ++ show (fmap fst r) L.putStrLn $ "tty = " <++?> tty @@ -132,18 +139,11 @@ ttyToXorgs tty_pids = do let dts = catMaybes dts' return dts -identifyTTY uid inode = do +identifyTTY tty_pids uid inode = do pid <- scanProc (show uid) (L.unpack inode) -- putStrLn $ "scanProc --> "++show pid flip (maybe (return Nothing)) pid $ \(pid,ttydev) -> do tty <- ttyOrDisplay pid ttydev - - us <- users - let filterTTYs (_,tty,pid) = - if L.take 3 tty == "tty" - then Just (tty,pid) - else Nothing - tty_pids = mapMaybe filterTTYs us -- putStrLn $ "users = " ++ show tty_pids dts <- ttyToXorgs tty_pids -- cgit v1.2.3