Skip to content

agents: fix rare broken pipe warning in stat version detection#926

Open
osedlbauer wants to merge 1 commit into
Checkmk:masterfrom
osedlbauer:fix/stat-broken-pipe-error
Open

agents: fix rare broken pipe warning in stat version detection#926
osedlbauer wants to merge 1 commit into
Checkmk:masterfrom
osedlbauer:fix/stat-broken-pipe-error

Conversation

@osedlbauer

Copy link
Copy Markdown

General information

OpenWrt-based device running the Checkmk agent. Affects the version detection logic stat --version.
stat is provided by the coreutils-stat package (GNU coreutils), not busybox built-in stat.

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 pipe

  • Steps to reproduce: run stat --version | head -1 | cut -d" " -f4 in a loop. The error appears occasionally (more frequently on low-performance targets).

Proposed changes

  • Expected behavior: version detection runs silently, no stderr output.
  • Observed behavior: head -1 closes its end of the pipe after reading the first line. If stat --version hasn'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.
  • Fix: redirect stderr to /dev/null for this call, suppressing the spurious warning.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant