Repository navigation
Avoid pipefail in monitor pid lookup - #513
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the monitor PID liveness lookup used by airc status (and the shared _monitor_alive_with_bearer_fallback helper) to avoid pipefail-triggered failures from piping PID lists into head -1, by introducing a helper that returns the first verified live monitor PID without using a pipeline.
Changes:
- Add
_airc_pidfile_first_live_monitor_pidto fetch the first live, cmdline-validated PID from a scope pidfile without piping tohead. - Update
_monitor_alive_with_bearer_fallbackandcmd_statusto use the new helper instead of_airc_pidfile_live_monitor_pids | head -1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/airc_bash/cmd_status.sh |
Switches status PID selection to the new non-pipeline helper. |
airc |
Adds _airc_pidfile_first_live_monitor_pid and uses it in monitor liveness detection to avoid pipefail/SIGPIPE from head -1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+540
to
+556
| _airc_pidfile_first_live_monitor_pid() { | ||
| local pidfile="${1:-}" | ||
| [ -f "$pidfile" ] || return 0 | ||
| local p raw | ||
| raw=$(cat "$pidfile" 2>/dev/null) | ||
| for p in $raw; do | ||
| case "$p" in ''|*[!0-9]*) continue ;; esac | ||
| if kill -0 "$p" 2>/dev/null; then | ||
| local _cmd | ||
| _cmd=$(proc_cmdline "$p" 2>/dev/null || true) | ||
| if _airc_cmdline_is_monitor_wrapper "$_cmd"; then | ||
| printf '%s\n' "$p" | ||
| return 0 | ||
| fi | ||
| fi | ||
| done | ||
| } |
| if [ "$(_monitor_alive_with_bearer_fallback "$pidfile")" = "yes" ]; then | ||
| if [ -f "$pidfile" ]; then | ||
| local first_alive; first_alive=$(_airc_pidfile_live_monitor_pids "$pidfile" | head -1) | ||
| local first_alive; first_alive=$(_airc_pidfile_first_live_monitor_pid "$pidfile") |
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.
Summary
_airc_pidfile_live_monitor_pids | head -1can SIGPIPE under pipefail when a host pidfile has multiple live AIRC PIDs_airc_pidfile_first_live_monitor_pidso liveness/status get the first verified PID without pipingairc statusnow prints full monitor/transport health instead of exiting after collaborationTests
Follow-up to #512 / #511.