[xmonad] sh-less spawn?

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Mon Sep 20 21:11:13 EDT 2010


On 21 September 2010 06:06, Joachim Breitner <mail at joachim-breitner.de> wrote:
> Hi,
>
> I just noticed this in my process list:
>
>  │           ├─xmonad-x86_64-l
>  │           │   └─sh -c gnome-terminal
>  │           │       └─gnome-terminal
>
>
> and the reason is here, in Core.hs:
>
> -- | Like 'spawn', but returns the 'ProcessID' of the launched application
> spawnPID :: MonadIO m => String -> m ProcessID
> spawnPID x = io . forkProcess . finally nullStdin $ do
>                uninstallSignalHandlers
>                createSession
>                executeFile "/bin/sh" False ["-c", x] Nothing
>  where
>    nullStdin = do
>        fd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags
>        dupTo fd stdInput
>        closeFd fd
>
> Generally, this is of course useful. But I bet that most commands passed
> to spawn are simple program names without arguments or any fancy
> shell-related stuff. Executing a shell here seems overkill. Not much,
> but still avoidable.

I believe the reason here is to do a double fork, such that when
xmonad restarts the program you launched via xmonad isn't killed.

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the xmonad mailing list