From f7c7496cfd700ab00a1bb5c2f96be137ea343e1c Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 30 Mar 2024 17:41:23 -0700 Subject: [PATCH] get_path should return None on failure --- mem_edit/linux.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mem_edit/linux.py b/mem_edit/linux.py index e6e92ad..80d6e0c 100644 --- a/mem_edit/linux.py +++ b/mem_edit/linux.py @@ -78,12 +78,12 @@ class Process(AbstractProcess): mem.readinto(read_buffer) return read_buffer - def get_path(self) -> str: + def get_path(self) -> str | None: try: - with open('/proc/{}/cmdline', 'rb') as f: - return f.read().decode().split('\x00')[0] + with open(f'/proc/{self.pid}/cmdline', 'rb') as ff: + return ff.read().decode().split('\x00')[0] except FileNotFoundError: - return '' + return None @staticmethod def list_available_pids() -> list[int]: