nanosleep: don't overwrite error with copyout success status
When nanosleep gets interrupted, it returns EINTR. In the case of a
non-zero error status, sys_nanosleep will copyout() the remaining sleep
time. However it would overwrite the nanosleep error status with the
error status of copyout() -- which is 0 (success) most of the time. This
means the important error status of nanosleep (EINTR) would be overwritten
by 0. Follow FreeBSD and NetBSD and only return the copyout status if it
failed.
Reported-by: walt