Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Observe reader signal cleanup without killing its terminal owner

pulse-triage[bot]0506a695817c
diff --git a/internal/api/configapi/install_command_test.go b/internal/api/configapi/install_command_test.go
index b7ea2811f1..d46eb77acc 100644
--- a/internal/api/configapi/install_command_test.go
+++ b/internal/api/configapi/install_command_test.go
@@ -82,7 +82,12 @@ while time.monotonic() < deadline:
silent = not (termios.tcgetattr(tty_watch)[3] & termios.ECHO)
if output.endswith(b"(paste at this prompt, not in the command): ") and command_ready and silent and not sent:
if p.get("signal_on_prompt"):
- os.killpg(child.pid, getattr(signal, "SIG" + p["signal_on_prompt"]))
+ # Keep the controlling terminal/session alive. The selected
+ # tool records the privileged reader that owns EXIT cleanup;
+ # signalling the entire session kills that observation owner.
+ with open(os.path.join(env["FAKE_ROOT"], "reader-pid")) as f:
+ reader = int(f.read())
+ os.kill(reader, getattr(signal, "SIG" + p["signal_on_prompt"]))
else:
os.write(master, (p["input"] + "\n").encode())
sent = True
diff --git a/internal/api/configapi/portable_bootstrap_test.go b/internal/api/configapi/portable_bootstrap_test.go
index f54a6b2eab..ec76a2a6b1 100644
--- a/internal/api/configapi/portable_bootstrap_test.go
+++ b/internal/api/configapi/portable_bootstrap_test.go
@@ -86,6 +86,7 @@ exec `+posixShellQuote(stty)+` "$@"
}
writeExecutable(t, filepath.Join(bin, "busybox"), `#!/bin/sh
printf '%s\n' "$*" >> "$FAKE_ROOT/tty-calls"
+if [ "$1" = stty ] && [ "$2" = -echo ]; then printf '%s\n' "$PPID" > "$FAKE_ROOT/reader-pid"; fi
exec "$FAKE_ROOT/native/busybox" "$@"
`)
} else if mode == "unsupported-busybox" || mode == "prefer-standalone" {
@@ -218,7 +219,7 @@ func TestPrivateBootstrapRealBusyBoxInput(t *testing.T) {
calls, err := os.ReadFile(filepath.Join(root, "tty-calls"))
lines := strings.Split(strings.TrimSpace(string(calls)), "\n")
if err != nil || len(lines) != 3 || lines[0] != "stty -g" || lines[1] != "stty -echo" || !strings.HasPrefix(lines[2], "stty ") {
- t.Fatal("snapshot, silent mode and full restoration did not use the selected real BusyBox applet")
+ t.Fatalf("snapshot, silent mode and full restoration did not use the selected real BusyBox applet: %q\n%s", lines, out)
}
assertPortableBootstrapPrivate(t, root, tc.input, out)
})