Skip to content

Allow nix-collect-garbage to skip certain files under /proc/*/fd/* #15595

@champignoom

Description

@champignoom

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


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposal
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions