Arming the pilots with guns is probably a bad idea. Namely because guns aren't actually all that practical in the enclosed space of the cockpit.
The issue of bullets putting a hole in the airplane does not matter much. Special bullets exist which are still effective enough against a human target, but will not pierce the side of an airplane. Sky marshals have been armed with these for some time.
However, arming the pilots with police-style batons may work better. In an enclosed space, the trigger-finger reflex on a gun becomes a severe bottleneck, because that reflex is among the slowest in the human body. If the pilots were prepared (as they undoubtedly would be, given the new safety requirements for cockpit doors), they should be able to handle anyone who comes through the door quickly and effectively.