[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] set linux file descriptor to O_CLOEXEC as default
From: |
Daniel Kiper |
Subject: |
Re: [PATCH] set linux file descriptor to O_CLOEXEC as default |
Date: |
Tue, 5 Nov 2019 13:07:40 +0100 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Tue, Nov 05, 2019 at 09:19:26AM +0000, Michael Chang wrote:
> We are often bothered by this sort of lvm warning while running grub-install
> or
> grub-install every now and then.
>
> File descriptor 4 (/dev/vda1) leaked on vgs invocation. Parent PID 1991:
> /usr/sbin/grub2-install
>
> The requirement related to the warning is dictated in the lvm man page.
>
> "On invocation, lvm requires that only the standard file descriptors stdin,
> stdout and stderr are available. If others are found, they get closed and
> messages are issued warning about the leak. This warning can be suppressed by
> setting the environment variable LVM_SUPPRESS_FD_WARNINGS."
>
> While it coulde be disabled through settings, most linux distributions seem to
> enable it by default and the justification provided by the developer looks to
> be valid to me.
>
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466138#15
>
> Rather than trying to close and reopen the file descriptor to the same file
> multiple times, which is rather cumbersome, for the sake of no vgs invocation
> could happen in between. This patch enables the close-on-exec flag (O_CLOEXEC)
> for new file descriptor returned by the open() system call, making it closed
> thus not inherited by the child process forked and executed by the exec()
> family of functions.
>
> Signed-off-by: Michael Chang <address@hidden>
Reviewed-by: Daniel Kiper <address@hidden>
Daniel