Solved

how to find pipe name associated with a file descriptor

Posted on 2011-09-23
6
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 
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

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 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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

696 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