When husband and wife live separate and apart from each other without being divorced, the circuit court or judge thereof, upon application of either, may grant a writ of habeas corpus to inquire into the custody of any minor unmarried child of the marriage, and may award the custody of such child to either for such time and under such regulations as the case may require. The decision of the court or judge must be guided by the rules provided by law for awarding custody of a minor or appointing guardians.
SDCL 25-5-9