A San Fernando police officer shot and killed a homeless man who he said attacked him with a tree branch outside a McDonald’s restaurant in San Fernando, police said on Thursday.

The shooting occurred outside Cork 'n Jug liquors at 901 Truman St. about 5:40 a.m. The man, whose name was unavailable, was died at a hospital.

A police officer was sent to the area on a report of a dispute between the man and another person at a nearby McDonald's.

The man who called police told officers he had been assaulted and spit on by a homeless man, said Lt. Mike Rosson of the Sheriff's Homicide Bureau.

A San Fernando police officer was getting out of his squad car when the homeless man attacked him with a large tree branch, Rosson said.

Police said the officer first used a stun gun to no effect before pulling his pistol.

As is routine in fatal officer-involved shootings, investigations are being launched by several agencies, including the Los Angeles County District Attorney’s Office, the LA County Coroner and sheriff’s homicide detectives.