[build] Fix Ctrl-C not aborting build (process_log.sh SIGINT)#25645
Merged
yxieca merged 2 commits intosonic-net:masterfrom Feb 26, 2026
Merged
[build] Fix Ctrl-C not aborting build (process_log.sh SIGINT)#25645yxieca merged 2 commits intosonic-net:masterfrom
yxieca merged 2 commits intosonic-net:masterfrom
Conversation
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
49db8f6 to
272d068
Compare
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Add SIGINT and SIGTERM trap handlers to process_log.sh so that pressing Ctrl-C during a build actually terminates the process pipeline. Root cause: The LOG macro in rules/functions pipes build output through process_log.sh: cmd < /dev/null |& process_log.sh -t >> target.log When the user presses Ctrl-C, make receives SIGINT and attempts to kill child processes. However, process_log.sh `while read` loop ignores SIGINT by default (bash builtin read is not interruptible in all cases), keeping the pipeline alive and preventing make from cleaning up and exiting. The fix adds explicit trap handlers that exit with the conventional signal exit codes (128+signal_number) when SIGINT or SIGTERM is received. Fixes: sonic-net#25520 Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com>
272d068 to
1275101
Compare
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines successfully started running 1 pipeline(s). |
yanmarkman
approved these changes
Feb 25, 2026
Collaborator
|
/azp run Azure.sonic-buildimage |
|
Azure Pipelines failed to run 1 pipeline(s). |
lihuay
approved these changes
Feb 25, 2026
FengPan-Frank
pushed a commit
to FengPan-Frank/sonic-buildimage
that referenced
this pull request
Mar 6, 2026
…net#25645) Add SIGINT and SIGTERM trap handlers to process_log.sh so that pressing Ctrl-C during a build actually terminates the process pipeline. Root cause: The LOG macro in rules/functions pipes build output through process_log.sh: cmd < /dev/null |& process_log.sh -t >> target.log When the user presses Ctrl-C, make receives SIGINT and attempts to kill child processes. However, process_log.sh `while read` loop ignores SIGINT by default (bash builtin read is not interruptible in all cases), keeping the pipeline alive and preventing make from cleaning up and exiting. The fix adds explicit trap handlers that exit with the conventional signal exit codes (128+signal_number) when SIGINT or SIGTERM is received. Fixes: sonic-net#25520 Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com> Co-authored-by: Rustiqly <rustiqly@users.noreply.github.com> Co-authored-by: Lihua Yuan <lihuay@users.noreply.github.com> Signed-off-by: Feng Pan <fenpan@microsoft.com>
dprital
pushed a commit
that referenced
this pull request
Mar 19, 2026
Add SIGINT and SIGTERM trap handlers to process_log.sh so that pressing Ctrl-C during a build actually terminates the process pipeline. Root cause: The LOG macro in rules/functions pipes build output through process_log.sh: cmd < /dev/null |& process_log.sh -t >> target.log When the user presses Ctrl-C, make receives SIGINT and attempts to kill child processes. However, process_log.sh `while read` loop ignores SIGINT by default (bash builtin read is not interruptible in all cases), keeping the pipeline alive and preventing make from cleaning up and exiting. The fix adds explicit trap handlers that exit with the conventional signal exit codes (128+signal_number) when SIGINT or SIGTERM is received. Fixes: #25520 Signed-off-by: Rustiqly <rustiqly@users.noreply.github.com> Co-authored-by: Rustiqly <rustiqly@users.noreply.github.com> Co-authored-by: Lihua Yuan <lihuay@users.noreply.github.com> Signed-off-by: dprital <drorp@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What I did
Add SIGINT and SIGTERM trap handlers to
scripts/process_log.shso that pressing Ctrl-C during a build actually terminates the build.Why I did it
Currently, pressing Ctrl-C during a SONiC build (especially during the trixie phase) does not reliably abort the build. The build appears to hang or continue running in the background.
Root cause: The
LOGmacro inrules/functionspipes all build output throughprocess_log.sh:When the user presses Ctrl-C:
makereceives it and tries to kill child processesprocess_log.sh'swhile IFS= read -r lineloop does not exit on SIGINT — bash'sreadbuiltin is not reliably interruptible by signalsFixes: #25520
How I did it
Added two trap handlers at the top of
process_log.sh:These ensure the script exits immediately when signaled, allowing the pipeline to tear down and make to clean up properly.
How I verified it
make SONIC_BUILD_JOBS=4 target/sonic-vs.img.gz