diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 33f7902916b6..74e1dc6bf1ba 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1832,6 +1832,13 @@ sendfile(struct proc *p, struct sendfile_args *uap) } done: + /* + * If there was no error we have to clear p->p_retval[0] + * because it may have been set by writev. + */ + if (error == 0) { + p->p_retval[0] = 0; + } if (uap->sbytes != NULL) { copyout(&sbytes, uap->sbytes, sizeof(off_t)); }