0

My problem is when I read from /dev/fd/3 with cat the bash file will hang. I'm hoping for a way to read from the file descriptor in the background so I can continue on to the rest of the shell code.

#hangs here. pipe file descriptor 3 to yummy-stdin.pl
cat /dev/fd/3 | yummy-stdin.pl

./this-shall-never-run.pl

I've tried:

cat /dev/fd/3 | yummy-stdin.pl & this-shall-never-run.pl;

The problem with the above is while it's processing this-shall-never-run.pl, it will stop reading from the file descriptor. When it's finished, it will continue reading... but this isn't what I want.

  • if i use `cat /dev/fd/3 > my_pipe` won't it just hang there? I dont see that solving my problem –  Feb 15 '13 at 02:45
  • How do you attach a stream to cat's fd 3? You'd normally do that with `... 3< some-file` or inheriting it from the parent. – Adrian Pronk Feb 15 '13 at 06:13
  • @StevenPenny This is not a duplicate of http://stackoverflow.com/q/12667621/mkfifo-causes-terminal-to-hang – Celada Feb 15 '13 at 15:19
  • @AustinAllover You are `cat`ing file descriptor 3, but what file does file descriptor 3 represent (in your shell)? Normally, if you haven't previously opened file descriptor 3 in your shell (with a command like `exec 3 – Celada Feb 15 '13 at 15:23

1 Answers1

0

Try this form of bash redirection instead along with tagging it as a background task:

yummy-stdin.pl $(< /dev/fd/3) &
./this-shall-never-run.pl
cwgem
  • 2,739
  • 19
  • 15