How does a flare gun work?

Flare guns are used in case of emergencies in many instances. If you get lost in the woods you can shoot off a flare gun to help search groups find you.