LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-03-2014, 08:23 AM   #1
Chickentree
LQ Newbie
 
Registered: Feb 2012
Posts: 5

Rep: Reputation: Disabled
finding per process open files


When a thread is created in linux it gets a copy of the processes file table. All the examples I have seen use a global variable to pass file descriptors for pipes etc. to children or threads but it would seem to me there must be a way to locate the file descriptor is the copied table the thread or child inherited.

what api's etc are available to look at a process / thread's file descriptor table in c / c++ ?
 
Old 02-03-2014, 09:42 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Since lsof was written specifically to show open files and has options to limit it to specific PIDs you might want to check out its source code to see how it gets that information.
 
1 members found this post helpful.
Old 02-03-2014, 10:28 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
What is your actual question? How can you enumerate every opened file-descriptor? /proc/<pid>/fd might be a start.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting open files for a process submerge Linux - Newbie 4 06-03-2013 12:29 PM
nagios plugin for monitoring the no. of open files for a particular process sarathveera Linux - Software 1 02-05-2010 12:43 AM
LXer: Finding The Number Of Open File Descriptors Per Process On Linux And Unix LXer Syndicated Linux News 1 11-25-2009 09:07 AM
LXer: Linux Process Management: Using lsof to List Open Files LXer Syndicated Linux News 0 04-10-2009 07:20 AM
Finding the Process ID of a Process While Initiating the Process senthilmuthiah Linux - Newbie 7 04-02-2009 10:37 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration