Re: Bash uses fd 255?

Richard B. Johnson (root@chaos.analogic.com)
Wed, 25 Mar 1998 15:27:22 -0500 (EST)


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