Whenever a writ of habeas corpus shall issue from either the supreme or superior court for the production and appearance before it of a prisoner confined in the adult correctional institutions, the writ shall be delivered to the division of sheriffs. Whenever the writ is issued from any other court, it shall be delivered to the division of sheriffs or to any town sergeant or chief of police or police constable, who shall duly present it to the director of corrections of the institutions. The director of corrections shall upon receipt of the writ deliver the prisoner to the custody of the officer. The officer shall take and receive the prisoner into his or her custody, shall duly present the prisoner before the court pursuant to the command of the writ, and shall keep and hold the prisoner until by order of the court he or she shall be recommitted to the institutions or otherwise disposed of. Upon the delivery of the custody of the prisoner by the director of corrections to the officer, the director of corrections shall endorse the delivery upon the writ, and the officer shall receipt on the books of the institutions for custody. The officer, upon the production of the prisoner in court, shall further endorse that fact on the writ and deliver it to the clerk or (if there is no clerk) the presiding justice; but shall, as an officer of the court, maintain safe custody of the prisoner until he or she is, by further order, recommitted or discharged.
R.I. Gen. Laws § 11-25-20