Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After creating a file descriptor by calling inotify_init() I add thousands of watches to the inotify instance(hope it is right to call that so).

My questions is if my program crashes what happens to those watch descriptors? Can I clear them all after the crash? It is important since allowed watch descriptor count is limited by /proc/sys/fs/inotify/max_user_watches

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

File descriptors, whether they point to files, sockets, or inotify instances, must belong to at least one process – they are automatically closed when the last process exits.

Similarly, when all file descriptors referring to an inotify instance have been closed, the underlying object and its resources are freed for reuse by the kernel; all associated watches are automatically freed. (inotify(7))

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.