[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Findutils-patches] [PATCH] Fix file descriptor leaks.

From: Eric Blake
Subject: Re: [Findutils-patches] [PATCH] Fix file descriptor leaks.
Date: Mon, 29 Mar 2010 16:03:46 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b1 Thunderbird/3.0.3

On 03/29/2010 04:29 AM, James Youngman wrote:
> +int
> +open_cloexec (const char *path, int flags)
> +{
> +  int fd;
> +

One more thing I just thought of: it would be wise to add:

assert ((flags & O_CREAT) == 0);

> +  fd = open (path, flags
> +#if defined O_CLOEXEC
> +          |O_CLOEXEC
> +#endif
> +          );

so that you don't accidentally create a file without passing the mode
argument here.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]