In 226, Cao Pi died (aged 40) and was succeeded by his eldest son Cao Rui (aged 22). Minister Chen Qun, General Cao Zhen, General Cao Xiu, and General Sima Yi were appointed as regents, even though Cao Rui was able to manage the government in practice. Eventually the former three died, leaving only Sima Yi as the senior minister and military commander. In 226, Sima Yi successfully defended Xiangyang against an offensive from Wu; this battle was the first time he had command in the field. In 227, Sima Yi was appointed to a post at Chang'an where he managed the military affairs along the Han River.