Register
It is currently Mon Oct 20, 2014 4:50 pm

enumerating file descriptors


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Sun Aug 05, 2012 7:19 am   

Joined: Fri Aug 03, 2012 2:07 pm
Posts: 20
This command does not return an exit status and does not complete. time peekfd <pid> where pid is that of the bash shell since that is the only process that was open on my terminal at that time. after more than an hour, the command had not returned. i wanted to enumerate the file descriptors for processes on my system before i ran into this loophole. who can help put me through on enumerating file descriptors. tnx


Top
 Profile  
 PostPosted: Sun Aug 05, 2012 10:10 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 550
what's the context?
be more precise, please, about what you're doing, what you want to achieve, and what you get.
know we're not beside you to see what you see.


Top
 Profile  
 PostPosted: Sun Aug 05, 2012 12:18 pm   

Joined: Fri Aug 03, 2012 2:07 pm
Posts: 20
i was reading the bash ref guide and trying to understand what file descriptors are.
so after "apropos peekfd" and "man peekfd" I ran the command: "time peekfd <pid>" where pid is a running process whose file descriptors i want listed. after more than an hour, the command had not exited or returned, so i decided to look for help.


Top
 Profile  
 PostPosted: Wed Aug 08, 2012 2:39 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
It's a pretty well-bugged program. It killed most of the processes I tried it on.

Well if you want to list file descriptors being used, taking bash(1) as an example:

Code:
$ pidof bash
4358 4319
$ ls /proc/4319/fd/
0  1  2  255
$ file /proc/4319/fd/*
/proc/4319/fd/0:   symbolic link to `/dev/pts/0'
/proc/4319/fd/1:   symbolic link to `/dev/pts/0'
/proc/4319/fd/2:   symbolic link to `/dev/pts/0'
/proc/4319/fd/255: symbolic link to `/dev/pts/0'
$


0, 1, 2 and 255 are file descriptors (FD) that represent their linked pseudo-terminal masters (PTM).

0 is the standard input (stdin); 1 is the standard output (stdout), and 2 is the standard error (stderr), by convention.

255 is returned to delimit the maximum file descriptors you can open, I think.
Or perhaps used not to collide with other ones (e.g., when sourcing). Or both.


0 is a pseudo-terminal slave (PTS) that's a pseudo-device with a text terminal interface, which is used
to communicate with device drivers (programs interacting with hardware devices) thanks to standard
input/output system calls which are processed by the kernel.



They are returned by the character file /dev/ptmx when opened: the process bash gets
independent FDs which are each associated to PTMs which are also associated to their
own PTSs created once the file descriptors are delivered to the process that ask for them.



If you want to intercept system calls, you can use strace(1) per example.


Top
 Profile  
 PostPosted: Sat Sep 15, 2012 9:37 am   

Joined: Fri Aug 03, 2012 2:07 pm
Posts: 20
thanks.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP