3
我想知道管道另一端的pid。如果是Linux,我可以像這些命令一樣匹配ls -l /proc/SELF_PID/fd/0
的ID。如何獲得管道另一側的pid?
[[email protected] ~]# command1 | command2 & I've known command2's PID = 5912. [[email protected] ~]# ls -l /proc/5912/fd/0 lr-x------ 1 root root 64 Mar 25 18:00 /proc/5912/fd/0 -> pipe:[540748072] [[email protected] ~]# ls -l /proc/[0-9]*/fd/1 | grep 'pipe:\[540748072\]' l-wx------ 1 root root 64 Mar 25 18:01 /proc/5911/fd/1 -> pipe:[540748072] [[email protected] ~]# cat /proc/5911/cmdline vmstat12
Linux上有更好的方法嗎?或如何獲得BSD和其他操作系統?
而且我想知道如果有一個很好的CPAN模塊...
感謝。
爲什麼你需要知道誰在管道上聆聽? – DarkDust 2011-03-25 09:14:08
我想使用stdin管道另一側的命令名稱命名日誌文件。 – riywo 2011-03-25 09:25:56
但是如果我做了'tee_log
DarkDust
2011-03-25 09:56:43