Fighting with a handgun in a confined space can be a challenge for anyone, regardless of training or equipment. Think about how you can get boxed in with no quick way to gain and maintain standoff distance—in an elevator, in a parking garage, small offices, in an alley or an alcove at a doorway. If you find yourself literally with your back against a wall, there are a few things you need to think about and incorporate into your recurring training plan.
First and foremost, keep control of your firearm. The only thing worse than getting shot is getting shot with your own gun. Understand that extending the gun so you can see the sights may be inviting the attacker to grab it and try to take it away, or possibly render it unusable by pushing the slide out of battery or preventing the cylinder from turning. Therefore, it is imperative to get some training on how to use your handgun close in, firing from what is known as "retention" or "index." There are some serious safety concerns for the uninitiated with this maneuver, so I strongly recommend attending a reputable training class on how to do this safely.
If, however, you find yourself at arm's length from an attacker, a good technique is to use your support arm to protect yourself, strike the attacker or at least keep the attacker from closing in while you draw your handgun with the strong hand.
If you carry strong-side hip or kidney, turning so your body is between the gun and the attacker may prevent the assailant from interfering with your draw or grabbing the gun.
If you carry up front in the appendix position, turning away may help, but if you turn too far, your back is exposed and that may cause more problems. Either way, train on getting the gun out with only the strong hand.
What I call "index" shooting is pressing the magazine bottom (with the strong hand on the pistol) against my side with the gun angled away to keep the slide from hitting me and/or clothing getting caught up in the operation of the handgun. This also adds stability, so the muzzle does not flip too much when firing multiple rounds. With a little training you can easily put three or more rounds into the vitals of an attacker, even if he is more than 3 feet away, which can come in handy if you are backing away and the bad guy is closing on you. Use dry fire to practice this skill—a lot—before live firing.
Don't forget to always keep your support hand high and out of the way, so you don't shoot your own hand—I recommend having the support hand in contact with your head when you first try this. Train safe, but train to stay alive.