Yes, in the United States, it is highly likely that there is an armed pilot in the cockpit of many commercial flights through the Federal Flight Deck Officer (FFDO) program. Established after 9/11, this voluntary program allows eligible pilots and flight engineers to undergo intensive training by the Federal Air Marshal Service to carry a firearm (typically a 9mm Glock 19) to defend the flight deck against acts of terrorism or air piracy. These pilots are considered federal law enforcement officers while on duty. While the exact number of armed pilots is a closely guarded secret, it is estimated that roughly 1 in 10 US pilots are part of the FFDO program. When the cockpit door is bolted, these pilots are trained to remain inside and defend the controls at all costs. Outside of the US, policies vary wildly, but the vast majority of international airlines do not permit pilots to carry firearms.