From f73a79d647cc9fa346b4dcc1d4d77221a4f37c82 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Fri, 16 Jan 2026 12:04:32 -0800 Subject: [PATCH] Fix another warning from LVM about leaked file descriptors, this time when calling "lvcreate" from a command hook (#1230). --- NEWS | 2 ++ borgmatic/hooks/command.py | 1 + tests/unit/hooks/test_command.py | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 780be6ac..5a014293 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,8 @@ * #1224: When running an "extract" check with the "--progress" flag, show file extraction progress. * #1225: Improve performance and greatly reduce memory usage during pre-backup safety validation on large filesystems. + * #1230: Fix another warning from LVM about leaked file descriptors, this time when calling + "lvcreate" from a command hook. * #1234: Fix for the ntfy monitoring hook erroring on emojis in the "title" option. * When syslog verbosity is enabled, log to systemd's journal (if present) with structured data. See the documentation for more information: diff --git a/borgmatic/hooks/command.py b/borgmatic/hooks/command.py index a1c6014d..3bb22f17 100644 --- a/borgmatic/hooks/command.py +++ b/borgmatic/hooks/command.py @@ -179,6 +179,7 @@ def execute_hooks(command_hooks, umask, working_directory, dry_run, **context): shell=True, environment=make_environment(os.environ), working_directory=working_directory, + close_fds=True, ) finally: if original_umask: diff --git a/tests/unit/hooks/test_command.py b/tests/unit/hooks/test_command.py index 07c742a1..e7ebd4a1 100644 --- a/tests/unit/hooks/test_command.py +++ b/tests/unit/hooks/test_command.py @@ -204,6 +204,7 @@ def test_execute_hooks_invokes_each_hook_and_command(): shell=True, environment={}, working_directory=None, + close_fds=True, ).once() module.execute_hooks( @@ -229,6 +230,7 @@ def test_execute_hooks_with_umask_sets_that_umask(): shell=True, environment={}, working_directory=None, + close_fds=True, ) module.execute_hooks( @@ -252,6 +254,7 @@ def test_execute_hooks_with_working_directory_executes_command_with_it(): shell=True, environment={}, working_directory='/working', + close_fds=True, ) module.execute_hooks( @@ -296,6 +299,7 @@ def test_execute_hooks_with_error_logs_as_error(): shell=True, environment={}, working_directory=None, + close_fds=True, ).once() module.execute_hooks( @@ -340,6 +344,7 @@ def test_execute_hooks_without_commands_to_run_does_not_raise(): shell=True, environment={}, working_directory=None, + close_fds=True, ).once() module.execute_hooks(