There are many valid but different answers to this question. Some answers depend on the era of history and the location. In ancient times, escaping people would likely be taken prisoner and be made slaves. They may also be taken hostage, to compel the defenders of the city to surrender, or simply killed. Sometimes their lives were spared in exchange for "intelligence" about conditions inside the city. Some attackers would allow a short truce for people to evacuate if they wanted to. There are just so many possibilities that I do not think you can find one answer that covers most cases. At least in more modern times, warring parties tend to show more concern for civilians caught in the middle.
A few examples I gleaned from reading history:
The ancient Assyrians would slaughter those caught outside the city and impale them on poles in full view of the city, to discourage the city from resisting the Assyrian army.
The armies of Julius Caesar would likely send the people back, although sometimes they massacred indiscriminately.
When the Roman General Titus besieged Jerusalem, he allowed a truce for inhabitants of Jerusalem to flee before the final attack. He held them for a little while to question them about conditions in the city, and then let them go. (He did massacre those who chose to stay in the city and fight.)
During the 3rd Crusade, Richard the Lionheart executed prisoners in full view of the city of Acre that he was besieging, to compel the city to surrender.
In more modern times, the trend has been to let people out as refugees rather than to kill or imprison them.