Skip to content

Avoid pipefail in monitor pid lookup - #513

Merged
joelteply merged 1 commit into
canaryfrom
codex/fix-liveness-head-pipefail
May 5, 2026
Merged

joelteply merged 1 commit into
canaryfrom
codex/fix-liveness-head-pipefail

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

  • fix a follow-up shell bug from Fix WSL join liveness detection #512 where _airc_pidfile_live_monitor_pids | head -1 can SIGPIPE under pipefail when a host pidfile has multiple live AIRC PIDs
  • add _airc_pidfile_first_live_monitor_pid so liveness/status get the first verified PID without piping
  • verified local airc status now prints full monitor/transport health instead of exiting after collaboration

Tests

  • bash -n airc lib/airc_bash/cmd_status.sh
  • airc status in the continuum scope
  • bash test/integration.sh send_dead_monitor_dies
  • bash test/integration.sh monitor_liveness_process_evidence

Follow-up to #512 / #511.

Copilot AI review requested due to automatic review settings May 5, 2026 04:27
@joelteply
joelteply merged commit ffb5740 into canary May 5, 2026
8 checks passed
@joelteply
joelteply deleted the codex/fix-liveness-head-pipefail branch May 5, 2026 04:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_pid to fetch the first live, cmdline-validated PID from a scope pidfile without piping to head.
  • Update _monitor_alive_with_bearer_fallback and cmd_status to 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 thread airc
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")
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.

2 participants