manpage for close
is clear on its multithread use for a given file descriptor. However it's not stated really clear in case of duplicated file descriptors.
If i have a file descriptor duplicated (both point to the same resource), is that thread safe to perform close of each respective fd in different threads? There is a refcount used to release a resource at the last close, but is that access thread safe?
manpage for close
is clear on its multithread use for a given file descriptor. However it's not stated really clear in case of duplicated file descriptors.
If i have a file descriptor duplicated (both point to the same resource), is that thread safe to perform close of each respective fd in different threads? There is a refcount used to release a resource at the last close, but is that access thread safe?
Share Improve this question asked Feb 3 at 10:03 Viktor KhristenkoViktor Khristenko 9331 gold badge6 silver badges20 bronze badges 1 |1 Answer
Reset to default 2if i have a file descriptor duplicated (both point to the same resource), is that thread safe to perform close of each respective fd in different threads?
yes
There is a refcount used to release a resource at the last close, but is that access thread safe?
yes
write
) using the same file descriptor in the same process at the time the file descriptor is being closed by the process, but other than that, you do not need to worry about it. – Ian Abbott Commented Feb 3 at 10:43