Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ ignore = [
"FBT001", # boolean-typed positional argument in function definition
"PLR2004", # magic value used in comparison
"S101", # use of `assert` detected
"S602", # `subprocess` call with `shell=True`
"S603", # `subprocess` call
#"S602", # `subprocess` call with `shell=True`
"S603", # `subprocess` call: check for execution of untrusted input
"S607", # `subprocess` call without explicit paths
"SLF001", # private member accessed
]
6 changes: 3 additions & 3 deletions src/tests/test_leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def get_opened_socket() -> int:
"""GNU/Linux: a way to get the opened sockets count.
It will be used to check X server connections are well closed.
"""
cmd = f"lsof -U | grep {PID}"
output = subprocess.check_output(cmd, shell=True)
return len(output.splitlines())
output = subprocess.check_output(["lsof", "-a", "-U", "-Ff", f"-p{PID}"])
# The first line will be "p{PID}". The remaining lines start with "f", one per open socket.
return len([line for line in output.splitlines() if line.startswith(b"f")])


def get_handles() -> int:
Expand Down
Loading