Until judgment is given upon the return, the judge before whom the petitioner is brought may either commit the petitioner to the custody of the sheriff of the county, or place the petitioner in other custody as the petitioner’s age and other circumstances require.