* If a specific file object occupies a specific file descriptor, close the * file descriptor entry and drop a reference on the file object. This is a * convenience function to handle a subsequent error in a function that calls * falloc() that handles the race that another thread might have closed the * file descriptor out from under the thread creating the file object. */
| 2755 | * file descriptor out from under the thread creating the file object. |
| 2756 | */ |
| 2757 | void |
| 2758 | fdclose(struct thread *td, struct file *fp, int idx) |
| 2759 | { |
| 2760 | struct filedesc *fdp = td->td_proc->p_fd; |
| 2761 | |
| 2762 | FILEDESC_XLOCK(fdp); |
| 2763 | if (fdp->fd_ofiles[idx].fde_file == fp) { |
| 2764 | fdfree(fdp, idx); |
| 2765 | FILEDESC_XUNLOCK(fdp); |
| 2766 | fdrop(fp, td); |
| 2767 | } else |
| 2768 | FILEDESC_XUNLOCK(fdp); |
| 2769 | } |
| 2770 | |
| 2771 | /* |
| 2772 | * Close any files on exec? |
no test coverage detected