[PR #1710] Fix --wait-pid for processes owned by other users #1700

Open
opened 2026-05-07 01:03:18 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/1710
Author: @bekoeppel
Created: 4/20/2026
Status: 🔄 Open

Base: mainHead: fix/wait-pid-eperm-and-pidof-docs


📝 Commits (1)

  • a0eb169 Fix --wait-pid false-negative for cross-user processes and pidof docs

📊 Changes

2 files changed (+9 additions, -3 deletions)

View changed files

📝 cmd/publish_unix.go (+8 -2)
📝 docs/subscribe/cli.md (+1 -1)

📄 Description

Two small fixes around ntfy pub --wait-pid.

1. processExists treats EPERM as "gone" (cmd/publish_unix.go)

kill(pid, 0) returns nil on success, ESRCH if the PID doesn't
exist, and EPERM if it exists but the caller can't signal it. The
current code treats any error as "doesn't exist", so --wait-pid
exits immediately when the target process belongs to another user.

Repro (before): as a regular user, against a root-owned process:

sudo sleep 300 &
ntfy pub --wait-pid $(pidof -s sleep) mytopic "done"
# -> "process with PID ... not running"  (wrong -- it's very much running)

After the fix, --wait-pid correctly blocks until the process exits.

Real-world case: ntfy running as a regular user waiting on a
root-owned restic backup.

2. pidof example uses -s (docs/subscribe/cli.md)

pidof rsync returns space-separated PIDs when multiple processes
match, which breaks --wait-pid's single-integer argument. pidof -s
(single-shot) returns just one.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/1710 **Author:** [@bekoeppel](https://github.com/bekoeppel) **Created:** 4/20/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/wait-pid-eperm-and-pidof-docs` --- ### 📝 Commits (1) - [`a0eb169`](https://github.com/binwiederhier/ntfy/commit/a0eb1697f06a9cf755c59937f7a2388555668b3c) Fix --wait-pid false-negative for cross-user processes and pidof docs ### 📊 Changes **2 files changed** (+9 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `cmd/publish_unix.go` (+8 -2) 📝 `docs/subscribe/cli.md` (+1 -1) </details> ### 📄 Description Two small fixes around `ntfy pub --wait-pid`. ### 1. `processExists` treats EPERM as "gone" (cmd/publish_unix.go) `kill(pid, 0)` returns `nil` on success, `ESRCH` if the PID doesn't exist, and `EPERM` if it exists but the caller can't signal it. The current code treats any error as "doesn't exist", so `--wait-pid` exits immediately when the target process belongs to another user. **Repro (before):** as a regular user, against a root-owned process: ``` sudo sleep 300 & ntfy pub --wait-pid $(pidof -s sleep) mytopic "done" # -> "process with PID ... not running" (wrong -- it's very much running) ``` After the fix, `--wait-pid` correctly blocks until the process exits. Real-world case: `ntfy` running as a regular user waiting on a root-owned `restic` backup. ### 2. `pidof` example uses `-s` (docs/subscribe/cli.md) `pidof rsync` returns space-separated PIDs when multiple processes match, which breaks `--wait-pid`'s single-integer argument. `pidof -s` (single-shot) returns just one. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1700
No description provided.