close syscall

int close(fd_t file);

Closes the file descriptor file. This does not necessarily immediately free the descriptor, as other processes or ongoing syscalls could still have a reference.

close merely decrements the reference count on the descriptor (initialized to 1 on open). When the reference count reaches zero the descriptor will actually be freed.

Returns 0 on success, negative errno on failure.