Skip to main content

Slightly tidy up this subprocess call

ID
fc7d210
date
2025-05-23 21:29:20+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
3a08b3d
message
Slightly tidy up this `subprocess` call
changed files
1 file, 5 additions, 3 deletions

Changed files

macos/find_processes_using_secure_input (3146) → macos/find_processes_using_secure_input (3173)

diff --git a/macos/find_processes_using_secure_input b/macos/find_processes_using_secure_input
index ade800d..59b91e9 100755
--- a/macos/find_processes_using_secure_input
+++ b/macos/find_processes_using_secure_input
@@ -50,16 +50,18 @@ def find_dicts_in_tree(d):
         pass
 
 
-def executable_name(pid):
+def executable_name(pid: int) -> str:
     """
     Returns the executable name associated with a given pid.
     """
-    return subprocess.check_output([
+    cmd = [
         "ps",
         "-c",              # Only show the executable name, not the full command line
         "-o", "command=",  # Only show the command column, no header
         "-p", str(pid)     # Only show the given process ID
-    ]).strip().encode("utf8")
+    ]
+    
+    return subprocess.check_output(cmd, text=True).strip()
 
 
 if __name__ == "__main__":