The inhabitants survived for another forty days before running out of provisions , ( many reports claim the starving inhabitants had to resort to eating dogs and rats in order to survive ) and surrendering on July 4 .