From f0451891b842c69d12ae06824e82e080bcba9ca8 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 2 Jan 2023 22:12:47 -0500 Subject: [PATCH] REF make spawnPipe clearer --- lib/XMonad/Internal/Shell.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/XMonad/Internal/Shell.hs b/lib/XMonad/Internal/Shell.hs index b8fa339..390d553 100644 --- a/lib/XMonad/Internal/Shell.hs +++ b/lib/XMonad/Internal/Shell.hs @@ -101,10 +101,7 @@ spawnPipeRW -> m Handle spawnPipeRW x = do (r, h) <- liftIO mkPipe - void $ withRunInIO $ \runIO -> do - X.xfork $ runIO $ do - void $ liftIO $ dupTo r stdInput - liftIO $ executeFile "/bin/sh" False ["-c", T.unpack x] Nothing + child r liftIO $ closeFd r return h where @@ -116,6 +113,10 @@ spawnPipeRW x = do hSetEncoding h utf8 hSetBuffering h LineBuffering return (r, h) + child r = void $ withRunInIO $ \runIO -> do + X.xfork $ runIO $ do + void $ liftIO $ dupTo r stdInput + liftIO $ executeFile "/bin/sh" False ["-c", T.unpack x] Nothing -- | Run 'XMonad.Core.spawn' with a command and arguments spawnCmd :: MonadIO m => FilePath -> [T.Text] -> m ()