The court may also, at the same time or afterwards, enter an order to the sheriff or other person to whom such attachment is directed, commanding him or her to bring forthwith before the court the party for whose benefit the habeas corpus order was entered, who shall thereafter remain in the custody of such sheriff, or other person, until the party is discharged, bailed or remanded, as the court directs.
735 ILCS 5/10-117