-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Allow nix-collect-garbage to skip certain files under /proc/*/fd/* #15595
Description
Is your feature request related to a problem?
When using nix under a proot-distro in termux, nix-collect-garbage -d always errors at failed readlink /proc/12345/fd/0: invalid argument, where 12345 is the pid of the proot process that spawns the whole distro, like an init process. This basically means that nix-collect-garbage fails to trace down the boundary between proot guest and termux host.
But it doesn't have to trace it further anyway. ls /proc/12345/fd/{0,1,2} shows three files with mode crw-------. They're actually /dev/pty/* under the hood, but proot doesn't make them symlinks but some block files, which is why readlink fails on them.
I'm not sure if /proc/*/fd/* not being symlink could be a design mistake on the proot side or not, but in any case, it would be convenient to be able to circumvent such problems giving exception rules.
Proposed solution
Add option like nix-collect-garbage --skip-fd=/proc/12345/fd/0 --skip-fd=/proc/12345/fd/1, so that the specified fd can be skipped.
Alternative solutions
Additional context
Checklist
- checked latest Nix manual (source)
- checked open feature issues and pull requests for possible duplicates
Add 👍 to issues you find important.