nanosleep: don't overwrite error with copyout success status
authorSimon Schubert <corecode@dragonflybsd.org>
Sun, 3 May 2009 21:06:53 +0000 (23:06 +0200)
committerSimon Schubert <corecode@dragonflybsd.org>
Sun, 3 May 2009 21:16:47 +0000 (23:16 +0200)
commit55d25c8782a76b25372313a908dff0a66d6ff342
treec335ec56d51ace9f7a2f40cc0f81f05d91e8e19a
parent54eeac0a18c59ef59ac1effb78adad42d7a675fd
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
sys/kern/kern_time.c