(a) It is the duty of the officer before whom a writ of habeas corpus is returnable, in case of such refusal or neglect on the part of the person to whom it is directed, to proceed forthwith against him by process of attachment, as for contempt, to compel obedience to the writ and to punish him for such contempt.
(b) When such attachment is issued against the sheriff or his deputy, it may be directed to the coroner or to any constable and may be executed by such coroner or constable.