From eb0f4eceeb809913b3b445e7040c6938b531b0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giovanni=20Ortu=C3=B1o=20Urquidi?= Date: Wed, 15 Jul 2026 15:32:50 -0400 Subject: [PATCH 1/3] process: Change timers to log the process being killed --- .../_internal/system/new_process.py | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/clusterfuzz/_internal/system/new_process.py b/src/clusterfuzz/_internal/system/new_process.py index 8a49dda19bc..6ed83036a1f 100644 --- a/src/clusterfuzz/_internal/system/new_process.py +++ b/src/clusterfuzz/_internal/system/new_process.py @@ -84,20 +84,38 @@ def wait_process(process, result = ProcessResult() is_windows = environment.platform() == 'WINDOWS' + def create_timeout_timer(interval, function, args): + """Helper to create a timer that logs timeout info.""" + def target(): + binary_name = os.path.basename(process.command[0]) + action_fn = args[0] + logs.info( + f"TIMEOUT: Terminating {binary_name} after {interval} seconds " + f"(using {action_fn.__name__})." + ) + function(*args) + return threading.Timer(interval, target) + # On Windows, terminate() just calls Win32 API function TerminateProcess() # which is equivalent to process kill. So, skip terminate_before_kill. if terminate_before_kill and not is_windows: first_timeout_function = process.terminate # Use a second timer to send the process kill. - second_timer = threading.Timer(timeout + terminate_wait_time, _end_process, - [process.kill, result]) + second_timer = create_timeout_timer( + timeout + terminate_wait_time, + _end_process, + [process.kill, result], + ) else: first_timeout_function = process.kill second_timer = None - first_timer = threading.Timer(timeout, _end_process, - [first_timeout_function, result]) + first_timer = create_timeout_timer( + timeout, + _end_process, + [first_timeout_function, result], + ) output = None start_time = time.time() From ada41bef967c9628a61714a16cb09ef30f1649c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giovanni=20Ortu=C3=B1o=20Urquidi?= Date: Wed, 15 Jul 2026 15:33:28 -0400 Subject: [PATCH 2/3] format --- src/clusterfuzz/_internal/system/new_process.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/clusterfuzz/_internal/system/new_process.py b/src/clusterfuzz/_internal/system/new_process.py index 6ed83036a1f..58539224ae3 100644 --- a/src/clusterfuzz/_internal/system/new_process.py +++ b/src/clusterfuzz/_internal/system/new_process.py @@ -86,14 +86,14 @@ def wait_process(process, def create_timeout_timer(interval, function, args): """Helper to create a timer that logs timeout info.""" + def target(): binary_name = os.path.basename(process.command[0]) action_fn = args[0] - logs.info( - f"TIMEOUT: Terminating {binary_name} after {interval} seconds " - f"(using {action_fn.__name__})." - ) + logs.info(f"TIMEOUT: Terminating {binary_name} after {interval} seconds " + f"(using {action_fn.__name__}).") function(*args) + return threading.Timer(interval, target) # On Windows, terminate() just calls Win32 API function TerminateProcess() From 6c541db5d6a0d86f099b47d9487998282b7bd83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giovanni=20Ortu=C3=B1o=20Urquidi?= Date: Fri, 17 Jul 2026 16:41:04 -0400 Subject: [PATCH 3/3] add docs --- src/clusterfuzz/_internal/system/new_process.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/clusterfuzz/_internal/system/new_process.py b/src/clusterfuzz/_internal/system/new_process.py index 58539224ae3..403c0375db6 100644 --- a/src/clusterfuzz/_internal/system/new_process.py +++ b/src/clusterfuzz/_internal/system/new_process.py @@ -85,7 +85,18 @@ def wait_process(process, is_windows = environment.platform() == 'WINDOWS' def create_timeout_timer(interval, function, args): - """Helper to create a timer that logs timeout info.""" + """Helper to create a timer that logs timeout info. + + This function takes the same arguments as threading.Timer. + + Args: + interval: The delay in seconds before the timer action is executed. + function: The function to be called when the timer expires. + args: The arguments to be passed to the function. + + Returns: + A threading.Timer object. + """ def target(): binary_name = os.path.basename(process.command[0])