{"id":5512,"date":"2016-07-03T06:25:30","date_gmt":"2016-07-03T11:25:30","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=5512"},"modified":"2016-07-03T06:25:30","modified_gmt":"2016-07-03T11:25:30","slug":"finding-the-other-end-of-a-unix-pipe","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2016\/07\/03\/finding-the-other-end-of-a-unix-pipe\/","title":{"rendered":"Finding the other end of a Unix pipe"},"content":{"rendered":"<p>If you need to see the other end of the a pipe, you can use either a find for the inode, or lsof, also on the inode.<\/p>\n<p>We see our process of interest is waiting on a read call from file descriptor 4&#8230;<\/p>\n<pre>\r\n[root@cmhlpdlkedat01 ~]# strace -f -p 20352\r\nProcess 20352 attached - interrupt to quit\r\nread(4, ^C <unfinished ...>\r\nProcess 20352 detached\r\n<\/pre>\n<p>&#8230;so we see it has the following inode&#8230;<\/p>\n<pre>\r\n[root@cmhlpdlkedat01 ~]# ls -lrt \/proc\/20352\/fd | awk '$(NF - 2) == 4'\r\nlr-x------ 1 postgres postgres 64 Jul  3 11:08 4 -> pipe:[2789099945]\r\n<\/pre>\n<p>&#8230;so we can either recursively search \/proc for the same inode&#8230;<\/p>\n<pre>\r\n[root@cmhlpdlkedat01 ~]# (find \/proc -type l | xargs ls -l | fgrep 'pipe:[2789099945]') 2>\/dev\/null\r\nlr-x------ 1 postgres postgres 64 Jul  3 11:08 \/proc\/20352\/fd\/4 -> pipe:[2789099945]\r\nlr-x------ 1 postgres postgres 64 Jul  3 11:11 \/proc\/20352\/task\/20352\/fd\/4 -> pipe:[2789099945]\r\nl-wx------ 1 postgres postgres 64 Jul  3 11:08 \/proc\/20406\/fd\/1 -> pipe:[2789099945]\r\nl-wx------ 1 postgres postgres 64 Jul  3 11:11 \/proc\/20406\/task\/19955\/fd\/1 -> pipe:[2789099945]\r\nl-wx------ 1 postgres postgres 64 Jul  3 11:11 \/proc\/20406\/task\/20406\/fd\/1 -> pipe:[2789099945]\r\n<\/pre>\n<p>&#8230;or use lsof&#8230;<\/p>\n<pre>\r\n[root@cmhlpdlkedat01 ~]# lsof | grep 2789099945\r\nsetup.php 20352  postgres    4r     FIFO                0,8        0t0 2789099945 pipe\r\nosm2pgsql 20406  postgres    1w     FIFO                0,8        0t0 2789099945 pipe\r\n[root@cmhlpdlkedat01 ~]#\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you need to see the other end of the a pipe, you can use either a find for the inode, or lsof, also on the inode. We see our process of interest is waiting on a read call from&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2016\/07\/03\/finding-the-other-end-of-a-unix-pipe\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[28,27],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5512"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5512"}],"version-history":[{"count":2,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5512\/revisions"}],"predecessor-version":[{"id":5515,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5512\/revisions\/5515"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5512"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}