Skip to content

Commit

Permalink
#777 / linux / open_files(): return also file flags
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Feb 27, 2016
1 parent dc46f4c commit 5c772a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def set_scputimes_ntuple(procfs_path):
'read_merged_count', 'write_merged_count',
'busy_time'])

popenfile = namedtuple('popenfile', ['path', 'fd', 'position', 'mode'])
popenfile = namedtuple('popenfile',
['path', 'fd', 'position', 'mode', 'flags'])
pmem = namedtuple('pmem', 'rss vms shared text lib data dirty')
pfullmem = namedtuple('pfullmem', pmem._fields + ('uss', 'pss', 'swap'))

Expand Down Expand Up @@ -1333,7 +1334,8 @@ def open_files(self):
# flags is an octal number
flags_oct = int(flags, 8)
mode = file_flags_to_mode(flags_oct)
ntuple = popenfile(path, int(fd), int(pos), mode)
ntuple = popenfile(
path, int(fd), int(pos), mode, flags_oct)
retlist.append(ntuple)
if hit_enoent:
# raise NSP if the process disappeared on us
Expand Down
1 change: 1 addition & 0 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ def open_files(self, ret, proc):
self.assertIsInstance(f.position, int)
self.assertGreaterEqual(f.position, 0)
self.assertIn(f.mode, ('r', 'w', 'a', 'r+', 'a+'))
self.assertGreater(f.flags, 0)
if BSD and not f.path:
# XXX see: https://github.com/giampaolo/psutil/issues/595
continue
Expand Down

0 comments on commit 5c772a1

Please sign in to comment.