Re: bash: Correct usage of F_SETFD

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

 



On 11/23/2010 07:42 AM, Matthew Wilcox wrote:
> The POSIX definition can be found here:
> http://www.opengroup.org/onlinepubs/009695399/functions/fcntl.html
> 
>> | 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.
>>
>> Yes, that seems to make more sense.
> 
> I think future flags will be created such that they default to off,
> and bash would have to affirmitively set them in order to use them.

Not true.  An implementation can reasonably define a new flag to off for
backwards-compatible behavior, and on for POSIX-compatible behavior, if
there is a case where traditional and POSIX behavior differ.  POSIX
permits additional bits to be on, and in fact requires that applications
leave those additional bits unchanged, in the very case where those
additional bits are essential for maintaining a POSIX-compatible
environment.

> 
> So if bash is the one creating its file descriptors, there's no need to
> use R/M/W since it knows what the state of them are.

No, bash cannot reasonably know what the implementation's default bit
state is, and blindly setting all other bits to zero is very possibly a
bug, and easy enough to avoid by using the full R/M/W.

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

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux