Bypass. The heart is stopped and the blood returning to the heart is instead diverted to the pump oxygenator, a machine that adds oxygen to the blood which is then pumped back into the aorta. So the surgery can be done with the heart stopped and with the blood bypassing the heart chambers. After the surgery on the heart is completed, the blood is directed back through the heart and lungs.
Very carefully. The heart is exposed via a sternotomy incision, the patients circulation is supported with cardiopulmonary bypass, the heart is arrested or stopped, the operation is done, then the patient is brought off bypass, incision closed.