bug-bash
[Top][All Lists]
Advanced

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

Re: Does HIGH_FD_MAX have to be so low?


From: Chet Ramey
Subject: Re: Does HIGH_FD_MAX have to be so low?
Date: Thu, 19 Oct 2006 15:33:37 -0400
User-agent: Thunderbird 1.5.0.7 (Macintosh/20060909)

Mike Stroyan wrote:

>   Looking at open_shell_script() in shell.c and move_to_high_fd() in
> general.c, I find that the code will force the use of fildes 255,
> (HIGH_FD_MAX), for reading the shell script when getdtablesize() reports
> that the maximum allowed file descriptor value is greater than 255.
> In this particular case the maximum file descriptor value was 1023,
> which would have stayed out of the way of the application's use.

If you look closely at move_to_high_fd(), you see that it attempts to
avoid file descriptors already in use.  Only if fcntl(fd, F_GETFD, ...)
returns -1 does it conclude that file descriptor fd is available.

One can debate whether or not we should be checking explicitly for
EBADF, but that's the only value of errno that's valid for F_GETFD
anyway.

I'd be interested in knowing why fcntl didn't return -1, if the parent
process really did leave the file descriptor open and didn't set the
close-on-exec flag.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                       Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]