Skip to content

Get files opened by a process #79

@giampaolo

Description

@giampaolo

From [email protected] on March 08, 2010 20:49:57

Considering that there's nothing like lsof implemented in python yet, it
would be very cool if psutil could provide a method to retrieve all the
files opened by a process as a list of path names.

Example:

>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.get_open_files()
['/etc/samba.conf', '/home/user/file.txt', ...]


I've found a working code for Windows, thanks to wj32 (we should really
thank the guy): http://forum.sysinternals.com/forum_posts.asp?TID=18892 ...which I managed to adapt to psutil in some way.

This is still not fully reliable as it lacks the routine to convert
"\Device\HarddiskVolume1\" into actual drive letters and a proper exception
handling, but I'd say it looks promising.

Original issue: http://code.google.com/p/psutil/issues/detail?id=79

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions