Repository: qtile/qtile

Issue:
Launching applications that require stdin input hangs qtile
Some applications like bashbug causes qtile to hangup. And the only way out is to kill X. Happens regardless if the program was launched by qtile or any other app.



Discussion:
Another case is for example launching vim from conkeror, hangs up everythin screen goes blank only cursor is visible.

Are you launching those apps (like conkeror) from config.py with your own code? I just started vim with my prompt that does lazy.spawncmd() and nothing broke at all.

are you using gvim, it works fine with graphical input, if you try running a terminal app vim-nox or anything that requires stdin, noticed this happens with spawn and spawncmd also spawning from conkeror launched from spawn, not sure if its related.

No, `vim`, not `gvim`. Even just `cat` has no issues.

I guess this has to do with the way you start qtile. Using .xinitrc + startx or some login manager? If .xinitrc, please post it here.

```
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

source ~/.zprofile
## launch agents
#eval $(/usr/bin/killall ssh-agent; /usr/bin/ssh-agent)
#eval $(/usr/bin/killall gpg-agent; /usr/bin/gpg-agent --daemon)
setxkbmap -option terminate:ctrl_alt_bksp &
xss-lock -- xscreensaver-command -lock &

if [[ $DISPLAY ]]; then
    xrdb -merge ~/.Xresources
    xset b 5 6000 600
    xset r rate 150 40
    xmodmap ~/.xmodmap
    xcompmgr &
    dbus-launch --auto-syntax --exit-with-session >~/.dbus-session
    source ~/.dbus-session
    #exec ~/.config/qtile/xsession
    #exec ~/bin/startdwm
    #exec starttde
    #exec awesome >~/.awesome.log
    # exec gnome-session
    # exec startkde
    # exec startxfce4
    # ...or the Window Manager of your choice
    #exec dbus-launch --sh-syntax --exit-with-session /usr/bin/awesome
    #exec dbus-launch --sh-syntax --exit-with-session /usr/bin/stumpwm
    #exec ~/bin/startdm
    xsetroot -cursor_name left_ptr
    exec qtile-session > ~/.qtile-xsession.log
    #exec dbus-launch openbox-session 
    #exec dbus-launch fluxbox
    #exec dbus-launch --exit-with-session dswm
    #exec dbus-launch --exit-with-session stumpwm
fi
```


Resolving patch:
diff --git a/libqtile/manager.py b/libqtile/manager.py
--- a/libqtile/manager.py
+++ b/libqtile/manager.py
@@ -1174,7 +1174,11 @@ def cmd_spawn(self, cmd):
 
                 spawn("firefox")
         """
-        pid, _, _, _ = gobject.spawn_async([os.environ['SHELL'], '-c', cmd])
+        pid, _, _, _ = gobject.spawn_async(
+            [os.environ['SHELL'], '-c', cmd],
+            flags=(gobject.SPAWN_STDOUT_TO_DEV_NULL |
+                   gobject.SPAWN_STDERR_TO_DEV_NULL)
+        )
         return str(pid)
 
     def cmd_status(self):
diff --git a/libqtile/widget/launchbar.py b/libqtile/widget/launchbar.py
--- a/libqtile/widget/launchbar.py
+++ b/libqtile/widget/launchbar.py
@@ -16,7 +16,6 @@
 from libqtile.widget import base
 import os.path
 import cairo
-import gobject
 from xdg.IconTheme import getIconPath
 
 
@@ -129,7 +128,7 @@ def button_press(self, x, y, button):
                 if cmd.startswith('qsh:'):
                     eval(cmd[4:])
                 else:
-                    gobject.spawn_async([os.environ['SHELL'], '-c', cmd])
+                    self.qtile.cmd_spawn(cmd)
             self.draw()
 
     def draw(self):


Test patch: