Skip to content

util: Make files opened via fsbridge::fopen() not inheritable by child processes #36668

Open

Description

@hebasto

Files opened via fsbridge::fopen() are inherited by child processes, such as -*notify or -signer commands.

They should not be, as a child has no business with the node's open files. On POSIX systems this can be achieved with O_CLOEXEC. On Windows, with the N mode flag (_O_NOINHERIT).

On Windows, this manifests as a functional test that passes all its cases and then fails to clean up:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: ‘D:\a\temp\test_runner₿🏃20261026_100424\feature_versionbits_warning_0\node0\regtest\debug.log’

Previously reported in #28529 and #27352.

Activity

  1. SirECMG commented on Oct 27, 2026

    @SirECMG

    Hi @hebasto,

    I would like to help contribute to this issue. I have read your comments on adding the O_CLOEXEC (POSIX) and _O_NOINHERIT). And have added the modes in src/util/fs.cpp.

    I have tested it in Linux(OpenSUSE distro), but still need to test it in OSX and Windows. But just wanted to check with you to see if the implementation of the PR is headed in the right direction.

    #36677: link to potential fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions