确定谁在监听 fifo 命名管道
Determine who is listening on fifo named pipe
假设我有一个命名管道:
mypipe="foobar"
mkfifo $mypipe
...稍后说我要给它写信
echo "foo" > $mypipe
如果没有人在听,我很确定这个回声调用挂起。在我进行回声调用之前,有没有办法确定是否有人正在从管道读取数据?
fuser
实用程序会告诉您谁拥有打开的句柄,但在一般情况下,它需要 root
权限。
引用 manual page,
fuser
may only be able to gather partial information unless run with privileges. As a consequence, files opened by processes belonging to other users may not be listed and executables may be classified as mapped only.
Installing fuser
SUID root
will avoid problems associated with partial information, but may be undesirable for security and privacy reasons.
假设我有一个命名管道:
mypipe="foobar"
mkfifo $mypipe
...稍后说我要给它写信
echo "foo" > $mypipe
如果没有人在听,我很确定这个回声调用挂起。在我进行回声调用之前,有没有办法确定是否有人正在从管道读取数据?
fuser
实用程序会告诉您谁拥有打开的句柄,但在一般情况下,它需要 root
权限。
引用 manual page,
fuser
may only be able to gather partial information unless run with privileges. As a consequence, files opened by processes belonging to other users may not be listed and executables may be classified as mapped only.Installing
fuser
SUIDroot
will avoid problems associated with partial information, but may be undesirable for security and privacy reasons.