Skip to content

[Linux] fix Process.open_files() for cases fdinfo has only flags (#2596) - #2598

Open
orionlee wants to merge 2 commits into
giampaolo:masterfrom
orionlee:fix_open_files_fdinfo_only_flags_2596
Open

orionlee wants to merge 2 commits into
giampaolo:masterfrom
orionlee:fix_open_files_fdinfo_only_flags_2596

Conversation

@orionlee

@orionlee orionlee commented Jul 4, 2025

Copy link
Copy Markdown

Summary

Description

Fix the issue in Process.open_files() in Google Cloud Run + Docker Linux Python image environment, where the fdinfo file of an opened file does not have the pos: line expected by existing psutil codes.

History and Credit additions

For HISTORY.rst:

- 2596_, [Linux]: `Process.open_files()` raises some IndexError in some environments
  such as Docker + Google Cloud Run

For CREDITS:

N: Sam Lee
W: https://github.com/orionlee
I: 2596

@orionlee
orionlee force-pushed the fix_open_files_fdinfo_only_flags_2596 branch from 6c1d2c0 to 099b8a2 Compare July 4, 2025 00:33
@orionlee orionlee changed the title [Linux] fix for cases fdinfo has only flags (#2596) [Linux] fix Process.open_files() for cases fdinfo has only flags (#2596) Jul 4, 2025
@christopher5106

Copy link
Copy Markdown

please merge

@christopher5106

Copy link
Copy Markdown
                    ntuple = popenfile(
                        path, int(fd), int(pos), mode, flags
                    )
                    retlist.append(ntuple)

does not work when pos is None

Signed-off-by: orionlee <orionlee@yahoo.com>
@orionlee
orionlee force-pushed the fix_open_files_fdinfo_only_flags_2596 branch from 099b8a2 to c59322f Compare December 23, 2025 00:05
…values (0) in cases pos or flags is missing.
@orionlee

Copy link
Copy Markdown
Author
  • Updated so that pos, flag would be 0s if they are not defined in the underlying fdinfo file
  • The failing test in CI ( macos-15, arm64 ) appears to be some unrelated issues on master.

@giampaolo giampaolo added bug type linux platform : Linux specific critical process dies, hangs forever, or memory is corrupt: segfault, deadlock, double free, crash on import badexc psutil raises something other than NoSuchProcess, AccessDenied, ZombieProcess or TimeoutExpired and removed critical process dies, hangs forever, or memory is corrupt: segfault, deadlock, double free, crash on import labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

badexc psutil raises something other than NoSuchProcess, AccessDenied, ZombieProcess or TimeoutExpired bug type linux platform : Linux specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Process.open_files() raises IndexError in some linux environments

3 participants