For a male western black widow spider, sex can be a life-or-death experience. His mate might decide to eat him, so he needs to find out whether she's hungry before committing himself.

Fortunately, the male has a powerful sense of smell. It's so acute, he can smell how peckish each female is just from the pheromones in their silk.

Black widow spiders get their name from the females' cannibalistic tendencies, but actually female western black widows only eat courting males about 2% of the time.

It was already known that black widow males are most attracted to well-fed females, but it was unclear how they knew.

A new study, published in the journal Animal Behaviour, now reveals that the males use their sense of smell.

"Male widow spiders may be choosy primarily to avoid the cost of encountering dangerous females, hungry females, that often kill males without letting them mate," says lead author Luciana Baruffaldi of the University of Toronto Scarborough in Canada.

The team exposed males to the sex pheromones of females that had been deprived of food for four weeks. The females had lost body mass and cut their silk production by over 50%.

The males showed a reduced response to the sex pheromones of these food-deprived females. If the females were ravenous, the males avoided them altogether.

The team also exposed female Australian redback spiders to the same experimental conditions. These females don't eat males during courtship, although they do often eat them during mating.

Evidently accepting that this was the price of sex, male redbacks were happy to mate with hungry females.

Though sexual cannibalism was extremely frequent among the redbacks, the males did get to father offspring before being killed.

"In the species where there is risk of sexual cannibalism before mating, males avoid the most risky females using the information encoded in the chemicals," says Baruffaldi. "However, in the species in which hungry females allow males to mate, this information seems to be irrelevant or absent."

Follow Melissa Hogenboom and BBC Earth on Twitter