& p指的是什么?

时间:2015-08-30 13:47:39

标签: shell unix background-process file-descriptor

我无法弄清楚以下脚本中的& p做了什么。并且print -u4是否意味着传递的任何参数都写在文件描述符4中?

1:  $SRVRMGRCMD |&
3:  BGPID=$!
4:  exec 4>&p
5:  exec 5<&p
6:  sleep 2
7:  # Build a list of Servers
8:  print -u4 "list servers show SBLSRVR_NAME"

提前致谢。

2 个答案:

答案 0 :(得分:1)

那是什么语言?

如果它是bash或shell,它会创建一个文件描述符来存储输出,请参见此处:

http://www.softpanorama.org/Tools/exec.shtml,特别是这部分:

exec 3< inputfile   # Opens inputfile with file descriptor 3 for reading.
exec 4> outputfile  # Opens outputfile with file descriptor 4 for writing.
exec 5<&0   # Makes fd 5 a copy of fd 0 (standard input).
exec 6>&p   # Attach fd 6 to co-process.

编辑说:

-u n 表示将所有输出写入文件描述符 n

见这里 http://alasir.com/books/bsd/428-430.html

答案 1 :(得分:1)

这些似乎是对协同进程的引用(在ksh或zsh中) 见https://unix.stackexchange.com/questions/86270/how-do-you-use-the-command-coproc-in-bash