You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realized there are two potential bugs in Process.get_connections() code on
Linux:
https://code.google.com/p/psutil/source/browse/tags/release-0.4.1/psutil/_pslinux.py#582
@wrap_exceptions
def get_open_files(self):
retlist = []
files = os.listdir("/proc/%s/fd" % self.pid)
for fd in files:
file = "/proc/%s/fd/%s" % (self.pid, fd)
if os.path.islink(file):
file = os.readlink(file)
if file.startswith("socket:["):
continue
if file.startswith("pipe:["):
continue
if file == "[]":
continue
if os.path.isfile(file) and not file in retlist:
ntuple = ntuple_openfile(file, int(fd))
retlist.append(ntuple)
return retlist
At line 589 we have a race condition in case "file" disappears (os.readlink()
fails with ENOENT which gets translated to NoSuchProcess).
At line 596, before os.path.isfile(file), we should check that "file" is an
absolute path.
If not we cannot tell whether "file" is valid or not because the check gets
made against process's current working directory.
From g.rodola on June 01, 2012 22:41:08
Original issue: http://code.google.com/p/psutil/issues/detail?id=272
The text was updated successfully, but these errors were encountered: