Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Mangement of fdtable[]



I was puzzling over Yen Chi Hsuan's bug report in 36866 so was looking
through tcp.c and noticed that it opens file descriptors with socket()
without marking them used in fdtable[].  The only time they're handled
"properly" is with "ztcp -l" which makes a movefd() call.

I think this means some fds may be closed in some cases they shouldn't,
or conversely left open in cases they shouldn't.  This may apply to fds
in other modules, e.g., the descriptor from gdbm_open() in db_gdbm.c.

This further led me to notice that when descriptors are manipulated in
utils.c, it carefully calls the static check_fd_table() function every
time to be sure the descriptor has a slot in the table before an FDT_*
value is poked for it.  Other parts of the code (mostly exec.c) simply
reference fdtable[N] without error checking.

I guess this is OK because fdtable[] is allocated zopenmax() slots in
zsh_main(), but it seems inconsistent if not actually wrong.

Comments?

-- 
Barton E. Schaefer



Messages sorted by: Reverse Date, Date, Thread, Author