Cain departed Thursday's contest after 3 1/3 innings. He allowed three runs on seven hits in San Francisco's 10-5 loss to Pittsburgh. Gaby Sanchez lined a pitch off the middle of Cain's arm.
"We are fortunate, and he is fortunate," said Giants manager Bruce Bochy, noting the injury could have been much worse. "That ball was smoked. But he's tough."
Cain has compiled an 8-8 record and 4.43 ERA this season. He has made every assigned start since joining the big league club in 2005.
Petit has appeared in one game for the Giants this season. In a relief outing in late July, he allowed two runs on six hits over 5 1/3 innings.
Zack Meisel is a reporter for MLB.com. Follow him on Twitter @zackmeisel. This story was not subject to the approval of Major League Baseball or its clubs.