REF make spawnPipe clearer

This commit is contained in:
Nathan Dwarshuis 2023-01-02 22:12:47 -05:00
parent 5b2c66033a
commit f0451891b8
1 changed files with 5 additions and 4 deletions

View File

@ -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 ()