From bfa7f4081828036364ad65c81379dfde8d77d15b Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Mon, 2 Jan 2023 20:57:07 -0500 Subject: [PATCH] WIP try dup-ing the read pipe to stderr --- lib/XMonad/Internal/Shell.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/XMonad/Internal/Shell.hs b/lib/XMonad/Internal/Shell.hs index 9dd671c..88566e7 100644 --- a/lib/XMonad/Internal/Shell.hs +++ b/lib/XMonad/Internal/Shell.hs @@ -93,26 +93,26 @@ spawnPipe :: (MonadReader env m, HasLogFunc env, MonadUnliftIO m) => T.Text -> m Handle -spawnPipe = fmap fst . spawnPipeRW +spawnPipe = liftIO . spawnPipeRW -spawnPipeRW :: MonadIO m => T.Text -> m (Handle, Handle) -spawnPipeRW x = liftIO $ do +spawnPipeRW :: T.Text -> IO Handle +spawnPipeRW x = do (rI, wI) <- createPipe (rO, wO) <- createPipe -- I'm assuming the only place this matters is when xmonad is restarted (which -- calls exec); since these are the ends of the pipe that xmonad will be -- using, this ensures they will be closed when restarting forM_ [wI, rO] $ \fd -> setFdOption fd CloseOnExec True - hI <- mkHandle wI - hO <- mkHandle rO + h <- mkHandle wI void $ X.xfork $ do void $ dupTo rI stdInput void $ dupTo wO stdOutput void $ dupTo wO stdError executeFile "/bin/sh" False ["-c", T.unpack x] Nothing + void $ dupTo stdError rO closeFd rI closeFd wO - return (hI, hO) + return h where mkHandle fd = do h <- fdToHandle fd