[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash: Correct usage of F_SETFD
From: |
Eric Blake |
Subject: |
Re: bash: Correct usage of F_SETFD |
Date: |
Mon, 22 Nov 2010 15:27:06 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.6 |
On 11/22/2010 03:16 PM, Chet Ramey wrote:
>> include/filecntl.h in bash-4.1 has following:
>>
>> #define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC))
>>
>> Is that really the correct/intended usage of F_SETFD ?
>
> F_SETFD Set the close-on-exec flag associated with fildes to
> the low order bit of arg (0 or 1 as above).
>
>> If kernel ever adds a new flag to the fd, this would end up clearing the
>> other new flag right ?
>>
>> Shouldn't bash use F_GETFD to get the current flags and set/clear just
>> the FD_CLOEXEC bit ?
>
> I suppose it would matter if there are systems that have more than one
> flag value.
In practice, there aren't any such systems; but POSIX warns that current
practice is no indicator of future systems, and that read-modify-write
is the only way to use F_SETFD.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature