Solved

how to find pipe name associated with a file descriptor

Posted on 2011-09-23
6
383 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now