On 07/21/2010 12:06 PM, Ralf Wildenhues wrote: > Hi Eric, Hi Ralf,
>> But maybe we want to do a global: >> >> for i in 3 4 5 6 7; do >> eval exec $i>&- >> done > > (why not just exec 5>&- 6>&- 7>&-?) Easier to extend if we wanted to clear out to fd 63 or some such (if seq were portable, then 'for i in $(seq 63); do...' would be easier than writing 60 >&- instances). But yeah, it makes more sense to only clear what we will explicitly use, rather than to clear arbitrarily high. > We don't do anything with fds 3 and 4; either we consider them special, > then shouldn't close them for that historical reason, or we could just > use them for internal purposes. Or decide now not use them because > we've never done so (and our users may have come to rely on that fact). We also document that users cannot rely on shell 'exec 3>file' to be preserved over an exec*(2) call (that is, fds 3 or larger may be marked cloexec when opened by the shell), and that other shells explicitly close all inherited fds 3 or larger on startup (that is, even if an fd is not cloexec in the shell's parent, it might be closed rather than inherited to the shell script body). So, on thinking about it more, there is no portable way to write a test that relies on external inheritance of an fd >= 3 opened by the parent of the testsuite; and within a portable test, you can use only fds 3 or larger only so long as you stick to shell constructs (you can't expect your C program or a subsidiary script to see those fds unless you used the shell to duplicate it onto one of the 3 standard streams). > > But anyway this still means that users wanting to pass extra fds to test > groups, should know that 5, 6, and 7 are reserved by Autotest, at least > for passing from outside the testsuite. And probably that 5 is better > avoided inside as well (I'm not sure if that's necessary, but it might > be at some point). Yeah, documenting that fd 5 is reserved for autotest logging may be worthwhile. But I don't see that holding up 2.67. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature