tech-userlevel archive

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

/bin/sh redirection in 'while' loop not closed afterwards?



Hi,

I observe this strange behaviour with /bin/sh on NetBSD-5.1 and current. It
seems that the redirection for the 'while' loop (fd 9 below) is not closed once
the loop finishes:

% /bin/sh
$ ls /proc/self/fd
0 1 2 3 4
$ while false; do :; done 9</dev/null
$ ls /proc/self/fd
0  1  10 2  3  4  9

This does not affect other commands, like ls:
$ ls / >/dev/null 9</dev/null
$ ls /proc/self/fd
0 1 2 3 4

I was wondering if this behaviour is expected (according to my understanding it
is not expected) or if this is a bug in /bin/sh. Other bourne shell that I
tried (like bash, ksh ...) do not show the problem.

PS: This is not just a cosmetic issue, because the actual file descriptor in
my application refer to a file on a NFS mounted directory, which makes a rm -rf
later fail because of a ".nfs" stalled entry.

Any comments welcome :)
Best regards,
Anthony


Home | Main Index | Thread Index | Old Index