Ensure headers are flushed to stdout in offcputime #5435
+4
−4
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 PR adds an explicit
fflush(stdout)after printing the headers in the libbpf-tools offcputime example.I am using this example as a dependency in another tool, where I monitor its standard output to determine when the tracer has successfully attached to a target process. Without an explicit flush, the header output appears to remain buffered and is never observed by the parent process, even after attachment.
By flushing stdout immediately after printing the headers, we ensure that the output is actually written once the tool has attached, making the behavior more reliable when stdout is being monitored or redirected. This change does not affect normal interactive usage but improves correctness in non-interactive and programmatic use cases.