static int close_on_exec (struct shim_fd_handle * fd_hdl, struct shim_handle_map * map, void * arg) { if (fd_hdl->flags & FD_CLOEXEC) { struct shim_handle * hdl = __detach_fd_handle(fd_hdl, NULL, map); close_handle(hdl); } return 0; }
struct shim_handle * detach_fd_handle (FDTYPE fd, int * flags, struct shim_handle_map * handle_map) { struct shim_handle * handle = NULL; if (!handle_map && !(handle_map = get_cur_handle_map(NULL))) return NULL; lock(handle_map->lock); if (fd < handle_map->fd_size) handle = __detach_fd_handle(handle_map->map[fd], flags, handle_map); unlock(handle_map->lock); return handle; }