I wanted to find all fds opened for a process in linux.
Can I do it with glib library functions ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you’re on Linux, you’ve (almost certainly) got the
/procfilesystem mounted. That means that the easiest method is going to be to get a list of the contents of/proc/self/fd; each file in there is named after a FD. (Useg_dir_open,g_dir_read_nameandg_dir_closeto do the listing, of course.)Getting the information otherwise is moderately awkward (there’s no helpful POSIX API for example; this is an area that wasn’t standardized).