I have a similar circumstance with habitual bears roaming the grounds. Black Bears. 200-400 lb.
Ideally, you'd want to carry something large bore, heavy bullet for caliber, and either hardcast flat tipped or JSP hunting loads depending upon revolver or semi-auto (and feeding reliability). You need something that will drive deep into a moving target that presents much more thickness protecting it's vitals than an upright human. The latest controlled expansion self-defense/duty JHP for use against humans is not necessarily the ticket. You want more than the 12"-18" gelatin block penetration that the FBI recommends for gunfights.
I would agree that any of the bigger revolvers that start with a ".4..." would be ideal. I've chosen S&W 4" .41 Remington Magnum revolvers just because I've owned/shot them for 40 years and it's my very favorite handgun caliber. Six shots is likely more than I'll ever be able to fire as a sprinting black bear closes on me from inside of 50 yards. Time for two shots is more likely. A black bear can outrun a horse. I'll either make good stopping hits or get used as a chew toy.
My bear duty house guns (for a problem in my yard, on the porch, etc.) are S&W Models 58 & 57. Ruger & Taurus offer revolvers in the same caliber (or .44) for less cost. There isn't a black bear alive that those guns can't handle.
Alternatively, a 10mm semi-auto with the heaviest, fastest loads it'll feed reliably should work fine. .41 Magnum Light. Glock 20.
Or... .40 S&W with 180-200 grain bullets moving at max velocity. Out of a duty sized gun like an HK USP (a gun with a fully supported chamber). Double Tap or Buffalo Bore flat tipped hunting loads at around 1000+ fps. 30-ish inches of penetration.
Or... .357 Magnum with bullets of similar weight. Again, out of a duty/hunting sized revolver. 4"-6" barrel. S&W or Ruger.
Or... even a .45 ACP +P 230 grains out of a full sized 5". Colt GM or equivalent.
If I got caught out with a 9mm, it would be with 147 +P and hope for the best. (I everyday CCW 9mm... but for deliberately walking local trails & roads among bears, I swap out for a bigger gun).
I have had two much-too-close encounters with black bears in my life, one of them at contact distance (bear leaning in and sitting on me through a Goretex pocket hotel tent wall). One in my back yard. Both times I was unfortunately armed with a 5-shot .38 J-Frame. If you ever want to feel inadequately armed, pointing a little .38 Special at a large bear at point blank range will do it. I was lucky both times and didn't have to shoot. Both bears curious but not aggressive. Thankfully.
Any handgun caliber that will take a large deer will also kill a black bear. But it might not stop one who's decided to scuff you up or eat you (black bears are actually statistically more predatory than their bigger cousin humpback bears). The question becomes one of deciding upon a gun/caliber combo that you can employ rapidly, under stress, against a blindingly fast animal that's turned aggressive.
Not the time and place for baby guns, short barrels, lighter weight bullets, or reduced velocity loads. 99% of the time, a Blackie is going to either go the other way... or simply ignore you and continue on with his feeding effort at the trash cans. Or instigate a bluff charge. But when/if the animal goes hostile and presses home an attack, you need to view it as the same kind of problem you'd have with a VBIED barreling down on you. You'll only get a few seconds (at most) to anchor him.
An advantage to the semi-auto route is that most will feature rails for a light. And most of my local bear encounters happen at night. Especially while out walking my dog in forested/brushy areas. This is good reason for Tritium night sights on an outdoor handgun as well. A dark colored animal buried in the dark shadows of vegetation is near impossible to aim at with standard sights. You just see a big dark blob and it's difficult to acquire a sense of where on his body your sights are actually pointed.
But a rail mounted light works better; really well as a matter of fact. I've found the ability to shine a bear rustling in the Oaks & Pines to be handy. I can usually interrupt them with the light at a distance (>50m) where neither of us are inside each other's personal space. They then generally decide to move off. And I don't need the added complication of trying to manipulate a hand held light while either controlling or dropping a dog leash. So for my nocturnal strolls, it's a .40 USP with TLR-1HL and 180 grain bullets. During daylight, one of the .41 Magnums.
So whatever you choose has to deliver a deep driving shot in a serious caliber, be absolutely reliable, be something you can make hits with against a fast moving target, and be something that can get the job done within 1-3 shots. Because any shots after that are going to be at muzzle contact distance.
Hmm...that's a lot of stream-of-unconsciousness crap posted above about something that I don't really view as a major problem. I live among bears and they're part of the local landscape. Used to humans and mostly well fed from a variety of rich food sources. Just another critter... like the resident coyotes, deer, and occasional lion. Incidents of bear aggression are very, very rare. But... the bears are there. And so am I. I've bumped into them enough times to be mindful. Thus, I've given some thought to exactly how I go about armed. Especially the night illumination & handgun caliber/load equations.