fix: improve script termination handling and signal processing #606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request improves the reliability and robustness of script execution and signal handling in both the script controller and workflow signal management. The main focus is on ensuring scripts and their child processes are properly finalized and terminated, handling edge cases around process cleanup, and improving the safety of signal delivery, especially when working with remote targets.
Process management and script finalization improvements:
kill_scriptfunction ininternal/script/script.goto wait up to 5 seconds for a script to clean up after receiving SIGINT, only sending SIGKILL if the process is still alive, ensuring child scripts have time to finalize._finalizeflag ininternal/script/scripts.goto prevent double-finalization and changed the trap to trigger onEXITas well asINTandTERM, ensuring profiling data is always finalized even if the script exits unexpectedly. [1] [2]waitcommands after stopping profiling processes to not fail if the process is already exited, increasing script robustness.Sequential script execution and signal handling:
current_seq_scriptto track the currently running sequential script, ensuring correct identification and termination during signal handling. Updated the signal handler to use this variable when killing the current script. [1] [2] [3] [4]Workflow signal handling and remote target reliability:
signalProcessOnTargetand added a delay before signaling local child processes, reducing the risk of losing controller output when working with remote targets. Improved logic to check for the existence of PID files and processes, and enhanced debug logging for better traceability. [1] [2] [3] [4]These changes collectively make the script execution and workflow management more robust, especially in scenarios involving remote targets or unexpected script exits.