2013-02-15 125 views
0

我的问题是当我从/dev/fd/3cat读取bash文件将挂起。我希望有一种方法可以从后台的文件描述符中读取,这样我就可以继续执行其余的shell代码。如何从shell脚本的后台读取文件描述符

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

./this-shall-never-run.pl 

我已经试过:

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

的问题与上面,而它的处理this-shall-never-run.pl,它将停止从文件描述符读取。完成后,它将继续阅读......但这不是我想要的。

+0

如果我使用'猫的/ dev/FD/3> my_pipe'不会只是挂在那里?我没有看到解决我的问题 – AustinAllover 2013-02-15 02:45:48

+0

你如何给猫的fd 3添加一个流?您通常会使用'... 3 2013-02-15 06:13:48

+0

@StevenPenny这不是一个重复的http://stackoverflow.com/q/12667621/mkfifo-causes-terminal-tohanghang – Celada 2013-02-15 15:19:16

回答

0

尝试这种形式的bash重定向,而不是随着标记它作为一个后台任务:

yummy-stdin.pl $(< /dev/fd/3) & 
./this-shall-never-run.pl 
相关问题