Skip to content

Commit

Permalink
Added function to find lingering methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Nilsson committed Nov 19, 2024
1 parent b9825c4 commit 280d47f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion PILOTVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.2.23b
3.9.2.23
2 changes: 1 addition & 1 deletion pilot/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
RELEASE = '3' # released number should be fixed at 3 for Pilot 3
VERSION = '9' # version number is '1' for first release, '0' until then, increased for bigger updates
REVISION = '2' # revision number should be reset to '0' for every new version release, increased for small updates
BUILD = '23' # build number should be reset to '1' for every new development cycle
BUILD = '24' # build number should be reset to '1' for every new development cycle

SUCCESS = 0
FAILURE = 1
Expand Down
20 changes: 20 additions & 0 deletions pilot/util/psutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,23 @@ def find_actual_payload_pid(bash_pid: int, payload_cmd: str) -> int or None:

logger.warning(f'could not find payload PID for bash PID {bash_pid}')
return None


def find_lingering_processes(parent_pid: int) -> list:
"""
Find processes that are still running after the specified parent process has terminated.
:param parent_pid: The PID of the parent process (int)
:return: A list of lingering process PIDs (list).
"""
if not _is_psutil_available:
logger.warning('psutil not available, cannot find lingering processes - aborting')
return []

lingering_processes = []
parent_process = psutil.Process(parent_pid)
for child in parent_process.children(recursive=True):
if child.status() != psutil.STATUS_ZOMBIE:
lingering_processes.append(child.pid)

return lingering_processes

0 comments on commit 280d47f

Please sign in to comment.