Solved

how to find pipe name associated with a file descriptor

Posted on 2011-09-23
6
379 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

19 Experts available now in Live!

Get 1:1 Help Now