Skip invalid file descriptors

This commit is contained in:
Isaiah Odhner 2024-11-02 11:37:26 -04:00
parent 00decf8217
commit 2a3c3f2d1d

View File

@ -53,6 +53,10 @@ def restart_program() -> None:
else:
p = psutil.Process(os.getpid())
for handler in p.open_files() + p.connections():
if handler.fd == -1:
# On Windows, this happens for kernel32.dll.mui, KernelBase.dll.mui, and about 4 sockets. Dunno man.
# print("Skipping invalid file descriptor (-1) for:", handler)
continue
try:
os.close(handler.fd)
except Exception as e: