首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我能用其他进程的管道做点什么吗?

我能用其他进程的管道做点什么吗?
EN

Stack Overflow用户
提问于 2021-07-25 10:40:24
回答 1查看 31关注 0票数 0

这里我想检查两个正在运行的进程之间的管道的状态。我可以使用ls -l/proc/pid/fd中识别两端的管道文件描述符,从而识别管道编号,如下所示:

代码语言:javascript
复制
l-wx------ 1 user user 64 Jul 22 08:53 5 -> 'pipe:[135687452]'

据我所知,管道在Linux vfs哲学中被视为一个文件,我怀疑有一些方法可以深入研究它,而不会干扰所有者进程。是否可以使用文件描述符或管道ID来访问更多的管道?我希望我能得到管道中的内容或管道中的内容长度。

非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2021-07-25 12:31:13

阅读实际内容会扰乱所有者的进程。不过,您可以使用FIONREAD查看内容长度。每个man 7 pipe

代码语言:javascript
复制
   The following ioctl(2) operation, which can be applied to a file
   descriptor that refers to either end of a pipe, places a count of
   the number of unread bytes in the pipe in the int buffer pointed
   to by the final argument of the call:

       ioctl(fd, FIONREAD, &nbytes);

   The FIONREAD operation is not specified in any standard, but is
   provided on many implementations.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68515136

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档