Find the answer to your Linux question:
Results 1 to 4 of 4
Hi All, How can I get the number of files that are kept open by a certain process at a certain time using C++ ? I want to call the ...
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    43

    Question Number of files that are kept open by a certain process

    Hi All,

    How can I get the number of files that are kept open by a certain process at a certain time using C++ ?

    I want to call the Linux system function that provides me with that information from within C++ source code, for which the number of open files kept open by itself matters to me.

    By the way, this C++ source code continuously opens up new files for writing.

    Thanks.

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    I'm not sure whether any system calls available to fetch this detail.
    But you can parse /proc/[pid]/fd to know how many files are used by the process denoted by pid.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Nov 2009
    Posts
    3
    I know the lsof command that will show open handles and the process.

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    thanks chris123a,Yes lsof command should work. But you need a function , then explore the source code lsof
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...