Solved

how to find pipe name associated with a file descriptor

Posted on 2011-09-23
6
391 Views
Last Modified: 2012-08-13
I use lsof, and one of the output is:
useA      10434  xsm111p1   13r     FIFO                0,6           56442761 pipe

the 13r I think it is file descriptor number that is associated with the pipe. how can I find the "file" that is associated with 13?
0
Comment
Question by:ndoung
  • 4
6 Comments
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 400 total points
ID: 36594192
Pipes don't have names (except named pipes). Regular pipes are just in-memory connections.
lsof does list the names of named pipes (they have a different major/minor device number as well)
0
 
LVL 21

Assisted Solution

by:Papertrip
Papertrip earned 100 total points
ID: 36594219
@duncan -- the lsof output says FIFO so it is a named pipe.

I tried to answer this question and couldn't get further than 'ls -l /proc/10434/fd'

That kinda works but if there are multiple named pipes then I couldn't figure out how to distinguish between them.  Any ideas?

BTW -- ndoung -- try that ls command I just wrote, it will kinda do what you want, not sure of your exact needs though so it might not.
0
 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 400 total points
ID: 36594335
@Papertrip No you are wrong. It says FIFO for all pipes, named or otherwise. I tried a named pipe, and the name was shown by lsof. Named pipe example follows, 3 screens
14:40:25$ mkfifo t5
14:40:48$ cat t5

Open in new window

Screen 1. create and read from named pipe
14:39:41$ cat >t5

Open in new window

Screen 2. write to named pipe
10:38:15$ lsof|grep -w t5
cat       4800       dunc    3r     FIFO        8,2      0t0   16237716 /home/dunc/tests/t5
cat       4801       dunc    1w     FIFO        8,2      0t0   16237716 /home/dunc/tests/t5

Open in new window

Screen 3. lsof output for named pipe
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 400 total points
ID: 36594352
Anonymous (regular) pipe example, 2 screens
14:48:19$ cat|cat

Open in new window

Screen 1. connect 2 processes with regular pipe
14:48:19$ lsof|grep cat|grep FIFO
cat       4829       dunc    1w     FIFO        0,7      0t0      28608 pipe
cat       4830       dunc    0r     FIFO        0,7      0t0      28608 pipe

Open in new window

Screen 2. lsof output for regular pipe
Both kinds of pipe exist in the underlying flat file system, in that they have an inode number. But a named pipe has a user directory entry while a regular pipe does not. I guess you could differentiate regular pipes by their inode numbers, that would be about the limit of what you could do.
0
 
LVL 34

Assisted Solution

by:Duncan Roe
Duncan Roe earned 400 total points
ID: 36595031
@ndoung - you are correct. 13r means file unit 13 open for reading - meant to post that originally
0
 

Author Comment

by:ndoung
ID: 36596530
I cd to /proc/<pid>/fd, and see file description 13 as below.
lr-x------ 1 xsm111p1 bband 64 Sep 25 18:29 13 -> pipe:[57921995]
So the pipe is regular and not named pipe. named pipe can have real file assocaited with it as /home/dunc/tests/t5.

duncan, papertrip, Thank you all  very much.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question