Mailing List Archive

Bash uses fd 255?
I'm working on a patch to provide an expandable fd array and have run into an
odd problem, apparently in bash. For some reason the shell is using the
sys_dupfd2 call to move fd 3 to fd 255, so that it ends up with fds 0, 1, 2, and
255. This of course forces my patch to expand the fd array even though only four
descriptors are in use.
Can anyone explain why this is being done?
Regards,
Bill
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Re: Bash uses fd 255? [ In reply to ]
Bill Hawes <whawes@star.net> writes:
|> I'm working on a patch to provide an expandable fd array and have run into an
|> odd problem, apparently in bash. For some reason the shell is using the
|> sys_dupfd2 call to move fd 3 to fd 255, so that it ends up with fds 0, 1, 2, and
|> 255. This of course forces my patch to expand the fd array even though only four
|> descriptors are in use.
|> Can anyone explain why this is being done?
Fd 255 is used internally as a connection to the tty, so that it doesn't
interfere with the use of exec to relocate fds. Bash also allocates high
fds when handling a process substitution `<(foo)', for the same reason.
--
Andreas Schwab "And now for something
schwab@issan.informatik.uni-dortmund.de completely different"
schwab@gnu.org
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Re: Bash uses fd 255? [ In reply to ]
On Wed, 25 Mar 1998, Bill Hawes wrote:
> I'm working on a patch to provide an expandable fd array and have run into an
> odd problem, apparently in bash. For some reason the shell is using the
> sys_dupfd2 call to move fd 3 to fd 255, so that it ends up with fds 0, 1, 2, and
> 255. This of course forces my patch to expand the fd array even though only four
> descriptors are in use.
>
> Can anyone explain why this is being done?
When executing a 'script' bash sets its private number of FDs to 255.
It then opens a script file, duplicating the fd to its max FD -1 so
that when it ultimately closes that FD it doesn't close the original
input/output FDs, leaving the shell with no interactive I/O.
Line 692 of shell.c in my version of bash.
Cheers,
Dick Johnson
***** FILE SYSTEM MODIFIED *****
Penguin : Linux version 2.1.90 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu