<div dir="ltr">But since writing "<&0" is equivalent to writing "0<&0" which is effectively meaningless not many of the shells interpret it as reconnecting input to stdin as bash does. <div>
<br></div><div style>Something like:  sh -c " cat <&3 3<&- & wait" 3<&0</div><div style><br></div><div style>might be more portable. </div><div style><br></div><div style>This information is taken from the link I posted rather than my own: <a href="http://unix.stackexchange.com/questions/71205/background-process-pipe-input">http://unix.stackexchange.com/questions/71205/background-process-pipe-input</a></div>
<div style><br></div><div style>So I'm not exactly why you would need to close the input to file descriptor 3 with "3<&-", left it in for good measure.</div><div style><br></div><div style>(may have something to do with making it unavailable or the subsequent commands.)</div>
<div> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 23 May 2013 09:59, Alain Williams <span dir="ltr"><<a href="mailto:addw@phcomp.co.uk" target="_blank">addw@phcomp.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, May 22, 2013 at 10:11:52PM +0100, Robert McKay wrote:<br>
> Greetings fellow Lugites,<br>
><br>
> I was wondering if anyone knows why these two commands behave<br>
> differently;<br>
><br>
> bash -c "cat & wait"<br>
> bash -c "cat <&0 & wait"<br>
><br>
> The first just exits right away. The second one does what I<br>
> wanted/expected the first one to do.<br>
<br>
</div>Running something in background causes its stdin to be connected to /dev/null.<br>
Thus:<br>
<br>
1) cat gets EOF immediately<br>
<br>
2) cat has its stdin *reconnected* to bash's stdin and thus reads whatever before<br>
   getting EOF<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Alain Williams<br>
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.<br>
<a href="tel:%2B44%20%280%29%20787%20668%200256" value="+447876680256">+44 (0) 787 668 0256</a>  <a href="http://www.phcomp.co.uk/" target="_blank">http://www.phcomp.co.uk/</a><br>
Parliament Hill Computers Ltd. Registration Information: <a href="http://www.phcomp.co.uk/contact.php" target="_blank">http://www.phcomp.co.uk/contact.php</a><br>
#include <std_disclaimer.h><br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
GLLUG mailing list<br>
<a href="mailto:GLLUG@mailman.lug.org.uk">GLLUG@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/gllug" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/gllug</a><br>
</div></div></blockquote></div><br></div>