On 10/27/2010 06:35 AM, Christian Weisgerber wrote:
> Paul Eggert:
> 
>> The relevant shell source code (in testsuite) is:
>>
>> # Tar should work when there are few, but enough, file descriptors.
>> ((ulimit -n 10 &&
>>   tar -cf archive3.tar a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- &&
>>   tar -xf archive3.tar -C dest3 a 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&-
>>  ) &&
>>  diff -r a dest3/a >/dev/null 2>&1
>> ) || { diff -r a dest3/a; exit 1; }
>> )"
> 
> Yes.  And I've set up the test directories manually and run the
> above from the command line--where it works fine for a limit of 8
> or more descriptors.
> 
> It only fails when called from the testsuite.
> 
> It succeeds from the testuite with -n 13 or more.

Using -n 13 is not helpful, since we can't guarantee that fd 10, 11, and
12 were not inherited into the shell running the test, but cannot
portably close them in shell.

On the dash mailing list, it was suggested that you try using exec
rather than redirection to close the fds.  That is:

( (exec 3<&- 4<&- 5<&- 6<&- 7<&- 8<&- 9<&- && ulimit -n &&
   tar -cf archive3.tar a &&
   tar -xf archive3.tar -C dest3 a
  ) &&
  diff -r a dest3/a >/dev/null 2>&1
) || { diff -r a dest3/a; exit 1; }
)

That way, you don't have the shell getting in the way by trying to dup()
fds to 10 in the first place.  Does that help matters any?

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to