<!DOCTYPE html>
<html><head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0, user-scalable=yes" name="viewport"/>
<title>HTML E-Mail</title>
</head><body class="email">
<p>Hi Ivan,</p>
<p class="quotelead" style="font-style: italic; margin-bottom: -1em; color: #999; font-size: 80%">On Tue, Jan 12, 2021 at 10:06:06AM -0500, ivan wrote:</p>
<blockquote class="quote initial" style="padding: 0 0.5em; margin: 0; font-style: italic; border-left: 2px solid #ccc; color: #999; font-size: 80%">
<p>In 'spawn', we close stdin in the child process, whereas in 'safeSpawn'<br/>
from xmonad-contrib we do not. I'm curious why that's the case?</p>
<p>This commit introduced the code that closes stdin, but doesn't describe the<br/>
{.quotelead}>motivation for doing so:</p>
</blockquote>
<blockquote class="quote initial" style="padding: 0 0.5em; margin: 0; font-style: italic; border-left: 2px solid #ccc; color: #999; font-size: 80%">
<p><a class="uri" href="https://github.com/xmonad/xmonad/commit/353e7cd6811245fbee7c8c6cf821041c924523b3">https://github.com/xmonad/xmonad/commit/353e7cd6811245fbee7c8c6cf821041c924523b3</a></p>
</blockquote>
<p>When you log in on a vt and do "startx $(which xmonad)", xmonad runs with fds 0, 1 and 2 connected to /dev/ttyN. If it didn't close (actually redirect from /dev/null) stdin, some programs might think they're being run from the terminal, I guess, and/or perhaps get stuck reading from it.</p>
<p>This is obviously a rather non-standard way of launching xmonad, so probably irrelevant, but:</p>
<p>The less unusual "startx" without arguments (having xmonad in .xinitrc or .xsession), /etc/X11/xinit/xinitrc invokes /etc/X11/Xsession which redirects stdout and stderr to .xsession-errors (this may be distro-specific, I'm on Debian), but it does not touch stdin, so that issue probably remains. I can't think of a specific app that breaks, off the top of my mind, but I'd be surprised if there weren't any.</p>
<blockquote class="quote subsequent" style="padding: 0 0.5em; margin: 0; font-style: italic; border-left: 2px solid #ccc; color: #999; font-size: 80%">
<p>And should we be closing it in 'safeSpawn' as well, or does<br/>
'safeSpawn' have a use-case that requires reading from stdin?</p>
</blockquote>
<p>I can't think of any such use-case. Using 'xfork' in 'safeSpawn' should be just fine.</p>
<div class="signature" style="color: #999; font-family: monospace; white-space: pre; margin: 1em 0 0 0; font-size: 80%"><span class="leader">-- </span><br/>Tomáš Janoušek, a.k.a. Pivník, a.k.a. Liskni_si, https://work.lisk.in/</div>
</body></html>