Is possible to know with system call `write(2)` if the fd that I'm sending data to is open or close?

My problem is that I'm writing to a fd that is sometimes closed and sometimes open. I think there must be a way to know with `write` this kind of situation but I can't find that.