It sounds good with one exception: bad guys will know that pilots are armed and could slit their throat in the concourse bathroom and then get on their flight where they would now have a gun.
If pilots do carry guns, the guns should stay in the cockpit and never be allowed in the concourse
where criminals could overpower one and take his/her gun. Other than that, good idea.
Using that logic perhaps we should give terrorists guns so that passengers could overpower them and then be armed against a terrorist attack.