SAN FRANCISCO  While Barry Bonds is on the verge of becoming baseball's home run king, his childhood buddy works in a prison kitchen for 12 cents an hour.

And there is no end in sight for his personal trainer, Greg Anderson.

Anderson is being held in contempt of court for refusing to testify before a grand jury investigating Bonds' alleged perjury. He's been there since November in this, his fourth and longest jail term connected to the federal government's seemingly endless investigation of steroid use by Bonds and other elite athletes.

This quiet, remarried 41-year-old father of a young son could remain incarcerated for many more months.

"He's not doing well, but he is doing," said lawyer and longtime friend Paula Canny, who has visited Anderson regularly at the Dublin Federal Correctional Institution.

Anderson will remain federal inmate No. 93389-011 until he testifies under oath about Bonds' alleged use of steroids, or until the term of the grand jury investigating the perjury allegations expires.

That could come as soon as Thursday, but prosecutors are widely expected to ask a judge to extend the grand jury's term. That could keep Anderson behind bars for up to six more months - or until he breaks his vow of silence.

Bonds needs just five homers to break Hank Aaron's record of 755.

"Greg's not talking, period," said his lawyer, Mark Geragos. He's among those who believe prosecutors will seek an extension of the grand jury's term.

"He's resolute as a rock," Geragos said.

The current grand jury investigation of Bonds can be traced to his late 2003 testimony before the BALCO grand jury. He said then, under oath, that he believed the substances he was given by Anderson were arthritis balm and flaxseed oil, rather than a newly developed steroid designed to evade detection, according to transcripts obtained by the San Francisco Chronicle.

Prosecutors are apparently convinced he was lying, but they need Anderson's testimony to prove it.

U.S. District Court Judge William Alsup sent Anderson back to prison last year after he refused to testify against Bonds.

Geragos said he's planning to soon ask Alsup to free Anderson by arguing that the trainer's imprisonment has now reached the level of being purely punitive instead of coercive - the goal of such civil confinements.

"It really has reached the point of absurdity," Geragos said.

A spokeswoman for the U.S. attorney's office in San Francisco, which is leading the Bonds investigation, declined to comment.

Alsup can also order Anderson's release if he decides imprisonment will not persuade the trainer to talk. But Alsup is not expected to be so moved any time soon.

In December, the judge declined to free Anderson even for a brief furlough that would have allowed him to spent Christmas with his 8-year-old son Cole. No further court dates have been set.

In the meantime, Anderson passes his time in the prison kitchen, a job the fitness buff requested in order to have better control over his diet.

"He was always eating eggs," said Joshua Wolf, a video blogger who served five months in prison with Anderson. Wolf, who was also jailed for refusing to cooperate with a government investigation of a separate matter, hasn't spoken to Anderson since his release in April.

Wolf and Anderson "ended up with an elevated status among a certain segment of people," Wolf said, in a prison rife with informants and inmates cooperating with government investigators.

"There were a couple of people who asked for Greg's autograph to send to relatives because Greg is connected to Barry Bonds and Barry is a legend," Wolf said. "You could tell he was flattered, but mostly embarrassed."

Wolf said the federal minimum security prison, located in an affluent suburb east of San Francisco, is more boring than dangerous.

"It was like being in an all-guys day camp, but you were waiting for a fishing trip that never comes," Wolf said.

Anderson declined an interview request. But by most accounts, he's everything Bonds is not: A failed baseball player who is considerate, kind and humble.

"He is one of the nicest guys I have ever met," Wolf said. "He is surprisingly un-jock like."

His decade-long friend and lawyer, Canny, said Anderson is more concerned with her recent diagnosis of breast cancer than with his own plight.

"He tells me that I have it worse. He's the nicest guy I have ever met," said Canny, a self-described gym rat who met Anderson at the same gym where he once worked out Bonds, a few blocks from the BALCO warehouse.

It's now called Family Fitness and the manager there declined to discuss Anderson. But in the lobby there is a can requesting $3 donations with a sign saying: "Support Greg Anderson." Donors receive a bumper sticker with the same message.

As children, Anderson and Bonds were neighbors in the San Mateo County suburbs, south of San Francisco. They played Little League baseball together before Anderson moved away during high school, and their paths separated for a time. Anderson's baseball career ended at Division II Fort Hays State in Kansas, where he was a power-hitting shortstop and designated hitter.

After the two were reunited through a mutual childhood friend, Bonds hired Anderson to be his personal trainer before the 1999 season, according to the book "Game of Shadows," by two Chronicle reporters.

The muscle-bound Anderson was then spending up to 12 hours a day in a Burlingame gym where steroids were openly bought and sold. It was a few blocks from the now-infamous Bay Area Laboratory Co-Operative, known as BALCO, which was raided by federal agents in 2003 and became the epicenter of sports' biggest doping scandal to date.

Anderson's home was raided on the same September day, and investigators found $60,000 in cash and a small amount of steroids.

He pleaded guilty to steroid distribution and money laundering charges and served three months in prison and three months of home detention.

Anderson's lawyers, Geragos and Canny, said he was offered probation in exchange for his cooperation. He refused, setting the stage for what was to come. If nothing else, Anderson has stuck to his vow not to participate in prosecutors' relentless pursuit of Bonds.

Geragos and others say Anderson's determination has everything to do with principle, and nothing to do with any financial arrangement or expected future deal with Bonds.