63

In Linux if you go digging in /proc/<pid>/fd often you'll see output like:

lrwx------ 1 root root 64 Jul 30 15:14 0 -> /dev/null
lrwx------ 1 root root 64 Jul 30 15:14 1 -> /dev/null
l-wx------ 1 root root 64 Jul 30 15:14 10 -> pipe:[90222668]
lr-x------ 1 root root 64 Jul 30 15:14 11 -> pipe:[90222669]
l-wx------ 1 root root 64 Jul 30 15:14 13 -> pipe:[90225058]
lr-x------ 1 root root 64 Jul 30 15:14 14 -> pipe:[90225059]

How do I get more info about the open pipes, such as which process is on the other end?

Kamil Kisiel
  • 11,946
  • 7
  • 46
  • 68

4 Answers4

56

Similiar to other answers, but:

lsof | grep 90222668

Will show you both ends, because both ends share the 'pipe number'.

Kyle Brandt
  • 82,107
  • 71
  • 302
  • 444
  • 4
    Ah, of course. Works as expected. You can even tell the file descriptor number and which end is the reader and which is the writer by looking at the 4th column of output! – Kamil Kisiel Jul 31 '09 at 18:07
  • I think that number might be the inode number of the pipe for pipefs which you can't mount. I am looking for a way to get inode to filename mappings, but this might be the best way. By the way, I love this question :-) – Kyle Brandt Jul 31 '09 at 18:24
  • Somehow this is not working for me. All it outputs is the pipe itself. – Rui Marques Mar 17 '14 at 10:23
  • running lsof as standard user may not give you information from all processes. Usually you don't have permission to see all processes' /proc//fd directory as a non-root user. – Andre Holzner Jun 03 '16 at 10:35
  • 6
    Also, you might want to use `lsof -n -P | grep 90222668` to avoid unnecessary name lookups, which should speed it up. – Wodin Oct 14 '16 at 11:48
  • for looking up with name of FIFO the following can be done. lsof -n | grep FIFO_NAME – snr Apr 18 '19 at 15:32
4

The only way to find what process is on the other end is by looping over all processes in /proc and seeing which are using that pipe (ie, which have symlinks in /proc/pid/fd to the same pipe ID)

bdonlan
  • 683
  • 7
  • 14
  • Thanks for the tip. One way to automate this is: `ls -l /proc/*/fd/ | grep $PIPE_ID; ls -l /proc/*/fd/$FD | grep $PIPE_ID` The first ls command will print the file descriptors of both ends of the pipe, while the second will give you the process id – Joao Costa Jan 25 '16 at 09:17
2

The most information I know how to get on open pipes is

lsof|grep FIFO

Still only tells about one end of it, I'm afraid.

chaos
  • 7,463
  • 4
  • 33
  • 49
1
lsof +E | grep FIFO | grep 90222668