Skip to content
  • David Howells's avatar
    Wrap accesses to the fd_sets in struct fdtable · 1dce27c5
    David Howells authored
    Wrap accesses to the fd_sets in struct fdtable (for recording open files and
    close-on-exec flags) so that we can move away from using fd_sets since we
    abuse the fd_set structs by not allocating the full-sized structure under
    normal circumstances and by non-core code looking at the internals of the
    fd_sets.
    
    The first abuse means that use of FD_ZERO() on these fd_sets is not permitted,
    since that cannot be told about their abnormal lengths.
    
    This introduces six wrapper functions for setting, clearing and testing
    close-on-exec flags and fd-is-open flags:
    
    	void __set_close_on_exec(int fd, struct fdtable *fdt);
    	void __clear_close_on_exec(int fd, struct fdtable *fdt);
    	bool close_on_exec(int fd, const struct fdtable *fdt);
    	void __set_open_fd(int fd, struct fdtable *fdt);
    	void __clear_open_fd(int fd, struct fdtable *fdt);
    	bool fd_is_open(int fd, const struct fdtable *fdt);
    
    Note that I've prepended '__' to the names of the set/clear functions because
    they requ...
    1dce27c5