Save/restore errno, like we do in safe_close(). And don't fork a thread if the parameter is already negative.
So that we can use it at multiple places.