Recently Written · git

sbm

dmenu bookmarks. Instantly fuzzy search thousands of bookmarks and plumb them. LOOKING FOR SUCKLESS SOFTWARE EDITION? GO TO sbm-suckless INSTEAD

git clone https://github.com/equwal/sbm

Log | Files | Refs


commit a15c97133266c326f2c9e99e33bcd26c8744b2c4
Spenser Truex <truex@equwal.com>
2026-09-22 22:48:06 -0700

sbm-setup stop: no error for a process that stops during the loop

A process can stop after the shell expands /proc/[0-9]*/cmdline and
before tr reads the file of the process. bm-watch does this when
"sbm-setup stop" stops its mintty. The shell then wrote "No such file
or directory", because 2>/dev/null came after the input redirection.
Put 2>/dev/null first.

 contrib/windows/sbm-setup | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/contrib/windows/sbm-setup b/contrib/windows/sbm-setup
index ec771aa..6113ce7 100755
--- a/contrib/windows/sbm-setup
+++ b/contrib/windows/sbm-setup
@@ -21,9 +21,12 @@ case ${1-} in
     stop)
         # The hidden mintty of bm-watch has the class sbm-watch. When it
         # stops, bm-watch gets SIGHUP and stops too. Cygwin shows the
-        # arguments of a process in /proc/PID/cmdline.
+        # arguments of a process in /proc/PID/cmdline. A process can stop
+        # during the loop, for example bm-watch after its mintty. Then the
+        # shell cannot open its file: 2>/dev/null comes first, so the shell
+        # writes that error to /dev/null.
         for f in /proc/[0-9]*/cmdline; do
-            case $(tr '\0' ' ' < "$f" 2>/dev/null) in
+            case $(tr '\0' ' ' 2>/dev/null < "$f") in
                 *'--class sbm-watch '*)
                     pid=${f#/proc/}
                     kill "${pid%/cmdline}" 2>/dev/null