Pulling a late-nighter? You might not want to reach for the sugary snacks to keep you awake. A new study involving fruit flies suggests the sleep-deprived mind is kept alert by hunger. 

The study, published Tuesday in the journal PLoS Biology, examined the effects of starvation on fruit flies that had been genetically engineered to be sensitive to sleep deprivation. Sleepy flies deprived of food stayed awake longer than sleepy flies that got meals. The starving flies also lived longer.

"From an evolutionary perspective, this makes sense," said study co-author Matt Thimgan, a Washington University postdoctoral researcher. "If you're starving, you want to make sure you're on the top of your game cognitively, to improve your chances of finding food rather than becoming food for someone else."

The researchers also found a gene that could explain the fruit fly's ability to resist the effects of sleep loss.

While the study may add insight into the role of sleep in humans' lives and health, the researchers warned that the findings aren't a recommendation for skipping dinners and staying up all night -- after all, the sleepy, starving fruit flies eventually died.

To tease out the relationships between sleep, starvation and survival, the researchers deprived fruit flies of both food and sleep. They found that starving fruit flies spent more time awake than satiated flies did. The researchers also tested the flies' saliva for enzymes that signal sleepiness and measured the flies' ability to associate a light with an unpleasant stimulus. Both tests showed that the starving flies were alert, not sleepy.

The starving flies also survived up to 28 hours without sleep, three times longer than the flies with access to food.

The survivors' ability is probably linked to a gene that helps the fruit-fly brain manage the storage and use of fat molecules called lipids, which include cholesterol, the researchers said.

In fact, the researchers were able to mimic the starvation effect by disabling a lipid management gene called Lipid storage droplet 2, or LSD2. The mutation seemed to allow the flies to rotate lipids rapidly in and out of cells, making it more difficult for the cells to use the lipids properly. As a result, the cells' ability to respond appropriately to sleep deprivation was impaired, and the flies stayed alert.

Previous research showed lack of sleep can cause obesity and contribute to diabetes and heart disease. But until now, no one had connected sleep to the genes that regulate cholesterol and other lipids, which have been linked to these diseases.

"It's becoming apparent that fats serve as signaling molecules in a number of contexts," said Clay Semenkovich, a Washington University lipid expert not involved in the study. "If you identify the appropriate lipids involved in sleep regulation and figure out how to control them, you may be able to decrease suffering associated with loss of sleep or the need to stay awake."

Top 10 Spooky Sleep Disorders

5 Things You Must Know About Sleep

7 Perfect Survival Foods