[xmonad] Launch without double-fork

Luis Cabellos zhen.sydow at gmail.com
Tue Dec 1 13:07:48 EST 2009


Hi, I was checking why there is two procces every time than I launch a
console. I found than spawn uses /bin/sh to lauch applications. I
think than to expecific commands is no need to double-fork,

I added the patch lo launch console without double-fork:

diff -rN old-xmonad/XMonad/Config.hs new-xmonad/XMonad/Config.hs
183c183
<     [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal
conf) -- %! Launch terminal
---
>     [ ((modMask .|. shiftMask, xK_Return), spawnf $ XMonad.terminal conf) -- %! Launch terminal
diff -rN old-xmonad/XMonad/Core.hs new-xmonad/XMonad/Core.hs
30c30
<     getAtom, spawn, spawnPID, getXMonadDir, recompile, trace, whenJust, whenX,
---
>     getAtom, spawn, spawnPID, spawnf, spawnPIDf, getXMonadDir, recompile, trace, whenJust, whenX,
406a407,424
> -- | spawnf. Launch an external application. It forks the application and
> -- runs the 'String' using the PATH to locate
> -- runs the 'String' you pass as a command to /bin/sh.
> spawnf :: MonadIO m => String -> m ()
> spawnf x = spawnPIDf x >> return ()
>
> -- | Like 'spawnf', but returns the 'ProcessID' of the launched application
> spawnPIDf :: MonadIO m => String -> m ProcessID
> spawnPIDf x = io . forkProcess . finally nullStdin $ do
>                 uninstallSignalHandlers
>                 createSession
>                 executeFile x True [] Nothing
>  where
>     nullStdin = do
>         fd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags
>         dupTo fd stdInput
>         closeFd fd
>


What do you think?

--

LC, ("There is no Dana, only Zuul." - Cazafantasmas [1984])


More information about the xmonad mailing list