Atomic print and re-print desc on status, flush before reboot#485
Merged
Atomic print and re-print desc on status, flush before reboot#485
Conversation
Refactor print() to emit description + final status in a single call to cprintf(), preventing kernel messages from splitting the two parts. For two-phase print(-1,...) + print_result() sequences used by, e.g., run_interactive, save the last description and re-print it before the [ OK ] / [FAIL] output so the status is never left stranded on a blank line when command output or kernel messages have scrolled away the original description. Finally, add print_exit() which drains the console output buffer with tcdrain(2) and resets ANSI SGR attributes + cursor visibility before the kernel takes back the console on reboot/halt, preventing escape code leakage into bootloader or early-kernel output. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the progress/status printing path to avoid kernel/command output interleaving with the final status marker, improves two-phase “pending + final result” output by re-printing the last description, and adds a shutdown-time console cleanup/drain helper before reboot/halt.
Changes:
- Refactor
print()to build description + final status into a singlecprintf()call for more atomic console writes. - Persist the last pending description and re-print it on
print_result()so[ OK ]/[FAIL]isn’t left detached. - Add
print_exit()and invoke it before reboot/poweroff/halt to drain output and reset console escape state.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/helpers.c |
Implements atomic final status printing, saves/reprints last description, adds print_exit() |
src/helpers.h |
Exposes print_exit() prototype |
src/sig.c |
Calls print_exit() before reboot/poweroff/halt |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Refactor
print()to emit description + final status in a single call tocprintf(), preventing kernel messages from splitting the two parts.For two-phase
print(-1,...)+print_result()sequences used by, e.g.,run_interactive(), save the last description and re-print it before the [ OK ] / [FAIL] output so the status is never left stranded on a blank line when command output or kernel messages have scrolled away the original description.Finally, add
print_exit()which drains the console output buffer withtcdrain(2)and resets ANSI SGR attributes + cursor visibility before the kernel takes back the console on reboot/halt, preventing escape code leakage into bootloader or early-kernel output.