Skip to content

Commit

Permalink
Added a library function which retruns linux process based on process…
Browse files Browse the repository at this point in the history
… name

Added a library function which retruns linux process based on process name

Signed-off-by: Praveen K Pandey <[email protected]>
  • Loading branch information
PraveenPenguin committed May 14, 2024
1 parent 17dd26c commit 5164ceb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions avocado/utils/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""

import os
import psutil

from avocado.utils import genio

Expand Down Expand Up @@ -72,3 +73,17 @@ def enable_selinux_enforcing():
if is_selinux_enforcing():
return True
return False


def get_processes_by_name(name):
"""
Return a list of processes matching 'name'
:param name: name of the process
:return: list of processes
"""
matching_processes = [
proc for proc in psutil.process_iter(["name"]) if proc.info["name"] == name
]
return matching_processes

0 comments on commit 5164ceb

Please sign in to comment.