Save and restore errno when opening the random device.