From 7ac38958fe7b9aee2fb6cd7ed4d859e032c76496 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Fri, 24 Apr 2026 13:17:26 -0500 Subject: [PATCH 1/2] Change get_pids_and_labels_on_host to only process grepped lines, instead of trying to match up pid/line. get_pids now ignores any line with ssh in it. --- rc/control/manage_processes_direct.py | 31 +++++---------------------- rc/control/utilities.py | 2 +- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/rc/control/manage_processes_direct.py b/rc/control/manage_processes_direct.py index e4b08d8a..8bde5bf6 100644 --- a/rc/control/manage_processes_direct.py +++ b/rc/control/manage_processes_direct.py @@ -817,39 +817,18 @@ def get_pids_and_labels_on_host(host, procinfos): os.environ["DAQINTERFACE_PARTITION_NUMBER"], ) ) - sshgreptoken = ( - "[0-9]:[0-9][0-9]\s\+ssh.*\(%s\).*application_name.*partition_number:\s*%s" - % ( - "\|".join( - set( - [bootfile_name_to_execname(procinfo.name) for procinfo in procinfos] - ) - ), - os.environ["DAQINTERFACE_PARTITION_NUMBER"], - ) - ) - - # greptoken = - # "[0-9]:[0-9][0-9]\s\+valgrind.*\(%s\).*application_name.*partition_number:\s*%s" - # % \ - # ("\|".join(set([bootfile_name_to_execname(procinfo.name) for - # procinfo in procinfos])), \ - # os.environ["DAQINTERFACE_PARTITION_NUMBER"]) grepped_lines = [] pids = get_pids(greptoken, host, grepped_lines) - ssh_pids = get_pids(sshgreptoken, host) - - cleaned_pids = [pid for pid in pids if pid not in ssh_pids] - cleaned_lines = [line for line in grepped_lines if " ssh " not in line] - + pids = [] labels_of_found_processes = [] - for line in cleaned_lines: + for line in grepped_lines: res = re.search(r"application_name:\s+(\S+)", line) - assert res - labels_of_found_processes.append(res.group(1)) + if res: + pids.append(line.split()[1]) + labels_of_found_processes.append(res.group(1)) return cleaned_pids, labels_of_found_processes diff --git a/rc/control/utilities.py b/rc/control/utilities.py index 7b748222..aac4b044 100755 --- a/rc/control/utilities.py +++ b/rc/control/utilities.py @@ -118,7 +118,7 @@ def host_is_local(host): def get_pids(greptoken, host="localhost", grepresults=None): - cmd = 'ps aux | grep "%s" | grep -v grep' % (greptoken) + cmd = 'ps aux | grep "%s" | grep -v ssh | grep -v grep' % (greptoken) if not host_is_local(host): cmd = "ssh -o BatchMode=yes -x %s '%s'" % (host, cmd) From 10dc517b3ed51d11bb92c37f20ce6b3bcd709e24 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Fri, 24 Apr 2026 14:15:37 -0500 Subject: [PATCH 2/2] Fix variable reference --- rc/control/manage_processes_direct.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/control/manage_processes_direct.py b/rc/control/manage_processes_direct.py index 8bde5bf6..d7b3372a 100644 --- a/rc/control/manage_processes_direct.py +++ b/rc/control/manage_processes_direct.py @@ -830,7 +830,7 @@ def get_pids_and_labels_on_host(host, procinfos): pids.append(line.split()[1]) labels_of_found_processes.append(res.group(1)) - return cleaned_pids, labels_of_found_processes + return pids, labels_of_found_processes def get_related_pids_for_process(procinfo):