You are kidding, right?
If a terrorist disguised as a pilot gets into the cockpit, just what is it that he would do with the gun? Shoot the co-pilot? Force the stewardess to bring him coffee?
What mechanism can be used to prevent bringing a firearm into the cockpit of a plane but which could somehow fail to prevent a terrorist disguised as a pilot from getting to the cockpit?
What would happen if a terrorist disguised as a sky-marshal brought a gun onto an aircraft? Is this a reason to disarm sky-marshals?