Skip to content



close_range - sys call to close a range of file descriptors


The close_range system call closes the file descriptors in the range [first,last], inclusive. This can be used in UNIX systems to reduce the number of times the same file descriptor is opened, as well as to free up resources and prevent resource leaks.

There are some edge cases to consider when using close_range. If a file descriptor is already open, it may not be possible to close it. Also, if multiple processes have the same file descriptor open, closing it within a single process may not free up the resource.


  • first:unsigned int[K] - the lowest file descriptor to be closed.
  • last:unsigned int[K] - the highest file descriptor to be closed.

Available Tags

  • K - Originated from kernel-space.
  • U - Originated from user space (for example, pointer to user space memory used to get it)
  • TOCTOU - Vulnerable to TOCTOU (time of check, time of use)
  • OPT - Optional argument - might not always be available (passed with null value)






To track the closing of a range of file descriptors.

Example Use Case

A system might use close_range to close all unnecessary file descriptors when loading a new process to maintain resources.


The close_range system call may not be able to close open file descriptors if they are already open in another process.

The open and close system calls may accompany close_range calls, as they are used to open and close individual file descriptors. Additionally, the dup, dup2 and dup3 calls can be used to copy/move file descriptors around.

This document was automatically generated by OpenAI and needs review. It might not be accurate and might contain errors. The authors of Tracee recommend that the user reads the "events.go" source file to understand the events and their arguments better.