summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/subr_syscall.c')
-rw-r--r--sys/kern/subr_syscall.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c
index 367ea67..5b48595 100644
--- a/sys/kern/subr_syscall.c
+++ b/sys/kern/subr_syscall.c
@@ -136,7 +136,8 @@ syscallenter(struct thread *td, struct syscall_args *sa)
AUDIT_SYSCALL_EXIT(error, td);
/* Save the latest error return value. */
- td->td_errno = error;
+ if ((td->td_pflags & TDP_NERRNO) == 0)
+ td->td_errno = error;
#ifdef KDTRACE_HOOKS
/*
@@ -191,9 +192,12 @@ syscallret(struct thread *td, int error, struct syscall_args *sa __unused)
syscallname(p, sa->code), td, td->td_proc->p_pid, td->td_name);
#ifdef KTRACE
- if (KTRPOINT(td, KTR_SYSRET))
- ktrsysret(sa->code, error, td->td_retval[0]);
+ if (KTRPOINT(td, KTR_SYSRET)) {
+ ktrsysret(sa->code, (td->td_pflags & TDP_NERRNO) == 0 ?
+ error : td->td_errno, td->td_retval[0]);
+ }
#endif
+ td->td_pflags &= ~TDP_NERRNO;
if (p->p_flag & P_TRACED) {
traced = 1;
OpenPOWER on IntegriCloud