2,220. A City Under Siege

Hilchos Issurei Biah 18:25

When the wife of a kohein is rendered prohibited because she was taken captive, since it’s based on doubt, she is permitted to live in the same courtyard as him so long as his children and the members of his household will always be around to keep an eye on him.

Hilchos Issurei Biah 18:26

Let’s say that a city was attacked and conquered. If the non-Jewish invaders surrounded the city on all sides so that it was impossible for a woman to escape without being seen and captured, then all the women of that city are prohibited to marry kohanim. They are treated as if they had been taken captive because they might have been molested by the invaders. Those under the age of three are exempted, as has already been explained.