Remix.run Logo
dundarious 9 hours ago

I like this tool. I just replaced a multi-step script to find running processes with deleted files open (e.g., updated shared library or binary) that used to be as follows:

- grep /proc/*/maps for " (deleted)" (needs root)

- exclude irrelevancies like paths starting with "/memfd:" (I have lots of other similar exclusions) with grep -v

- extract the pid from the filename part of grep's output with sed

- for each pid, generate readable output from /proc/$pid/cmdline (which is NUL separated) with tr, xargs, bash printf

- show the pid, cmdline, file path

Yes, this is what needs-restarting does too.

With this tool, this pipe chain is now just:

    doas psc -o "process.pid,process.cmdline,file.path" \
      'file.path.endsWith(" (deleted)") && !file.path.startsWith("/memfd:") && !...' \
      | sed 1d