Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Kadejia Gadson spent Sunday evening frantically texting her brother, a prisoner in South Carolina’s Lee Correctional Institution.

She had just seen photos on Facebook posted by inmates with contraband phones that appeared to show her 24-year-old brother, Damonte Marquez Rivera, lying in a pool of blood.

Rivera often sent her Snapchats and texts from his own smuggled phone, so Gadson hoped he would respond quickly. “Please reply you’re OK,” she wrote.

But as more photos were posted from inside the maximum-security prison showing rapidly escalating fights and bloodied bodies strewn on the floor, Gadson’s dread mounted. By the time authorities brought the prison under control, seven hours after the clashes began and a couple of hours after the photos of Rivera were posted online, he and six other inmates were dead.

“He sat there for two hours on the prison floor before he finally got help,” said Gadson, 18, who lives in Georgetown, South Carolina. “Nobody deserves that, no matter what happened.”

The brawls, which also left 17 inmates injured, were likely set off by disputes over territory and contraband, authorities said. The violence was so difficult to stop in part because the prison is severely understaffed: There were just four officers on duty for the 250 to 260 inmates in the dorm where the fighting broke out, according to South Carolina Department of Corrections Director Bryan Stirling.

The shortage of corrections officers is a problem across the South Carolina state prison system, which has led to an uptick in violence in recent years, according to reports and prison reform advocates. Lee Correctional Institution, which houses the state’s most violent criminals, has a staff shortage of 28 percent, which means officers are working overtime to fill the gaps, Stirling said at a news conference on Monday. According to The State, a newspaper based in Columbia, South Carolina, there are about 650 vacancies for correctional staff statewide.

Amid this staffing shortage, 12 prisoners were killed by fellow inmates last year in South Carolina’s prisons, according to The State. That’s up from five inmates in 2016 and three in 2015. The South Carolina Department of Corrections did not immediately respond to a request for this year’s numbers.

Damonte Rivera sent this photo to his sister the night before he was killed. Courtesy of of Kadejia Gadson

“The critical factor is, we’re not investing enough in prisons,” said Susan K. Dunn, legal director for the American Civil Liberties Union, South Carolina. “We don’t have enough guards and the reason we don’t have enough guards is we don’t pay them enough. We don’t really get the best people because we’re not willing to pay enough.”

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

More correctional officers have been hired recently, and their average starting salary this year was $33,289, according to the South Carolina Department of Corrections. That is up from $26,826 in 2014, which has helped to reduce officer turnover.

In his budget request this year, Gov. Henry McMaster, a Republican, included the full $5 million that the state's Department of Corrections requested for pay raises for officers. (South Carolina is still going through its budget process.)

"The governor is committed to continuing to fund raises at the agency and will continue to do that as long as the agency is in need," Brian Symmes, a spokesman for the governor, said.

Symmes said this is the first year "in quite some time" that there has been a net gain of correctional officers recruited and retained in the state.

But a union representing the state’s law enforcement officers said in a statement that the state still has a “sizable shortage of qualified correctional officers to oversee this state’s prisons.”

“Many times as few as one or two correctional officers oversee more than 250 inmates,” Ryan Alphin, executive director of the union, the South Carolina Law Enforcement Officers' Association, which represents both police officers and corrections officers, said in a statement to NBC News. “This is an issue in South Carolina as well as other states.”

To compensate for a lack of staffing, Dunn said prisons often resort to lockdowns, keeping prisoners in their cells.

“But then they don’t get visitors, they can’t get hot meals, they can’t exercise,” Dunn said. “It’s just a recipe for a problem.”

The 12 inmates killed in 2017 include four men at Kirkland Correctional Institution, another maximum-security prison, who were strangled by two convicts over the course of 30 minutes.

Carter Elliott, an attorney who represented the families of three of the inmates who were strangled, said training is a critical issue for staff in South Carolina’s prisons.

“They’re not properly trained to recognize people who need help,” Elliott said. “It starts with the number of people they have, but I don’t think the number of people they have are properly trained.”

Elliott, whose Georgetown-based practice handles 50 to 75 cases a year against detention centers, including South Carolina’s Department of Corrections, said he’s seen a recent spike in stabbing cases, as well as other types of violence.

On Sunday evening, handmade knives were the weapon of choice at Lee in what The Associated Press said was the deadliest prison riot in the United States in 25 years.

By the time it was over, bloody bodies were stacked on ”top of each other, like some macabre woodpile,” one inmate told the AP.

Prison guards followed protocol by backing out and asking for support, the AP reported. After several hours, SWAT teams entered and the inmates surrendered.

But that was too late for Rivera, the youngest of the six inmates who were killed. At 4 a.m. on Monday, Gadson said the prison called her family to tell them of her brother’s death.

“It really hurts, and now it’s hard to cry because it’s hard to believe,” she said. “I probably won’t get it until I see him.”

Rivera was serving a life sentence on a murder conviction. Regardless of his past, Gadson said, her brother deserved to be safe in prison.

“The night before we were talking about seeing each other,” Gadson said. “It’s sad the next time I’ll see him is him in a casket.”