agents: fix rare broken pipe warning in stat version detection#926
Open
osedlbauer wants to merge 1 commit into
Open
agents: fix rare broken pipe warning in stat version detection#926osedlbauer wants to merge 1 commit into
osedlbauer wants to merge 1 commit into
Conversation
head -1 closes the pipe after reading the first line. If stat --version has not finished writing yet, this causes a spurious warning, especially on low performance targets: stat: write error: broken pipe Fix this by redirecting stderr to /dev/null. Signed-off-by: Oliver Sedlbauer <os@dev.tdt.de>
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.
General information
OpenWrt-based device running the Checkmk agent. Affects the version detection logic
stat --version.statis provided by thecoreutils-statpackage (GNU coreutils), not busybox built-instat.Bug reports
OS: OpenWrt (coreutils-stat - 9.11)
The agent occasionally emits a spurious stderr message, when calling section_mounts in check_mk_agent.openwrt:
stat: write error: Broken pipeSteps to reproduce: run
stat --version | head -1 | cut -d" " -f4in a loop. The error appears occasionally (more frequently on low-performance targets).Proposed changes
head -1closes its end of the pipe after reading the first line. Ifstat --versionhasn't finished writing all its output yet, this causes a write to a closed pipe (EPIPE), which coreutils reports as "write error: Broken pipe" on stderr. The parsed version value itself is unaffected, only the stderr message is noisy.