summaryrefslogtreecommitdiff
path: root/sim/syscall_emul.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sim/syscall_emul.cc')
-rw-r--r--sim/syscall_emul.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc
index 4ae2d2631..50650018e 100644
--- a/sim/syscall_emul.cc
+++ b/sim/syscall_emul.cc
@@ -110,8 +110,11 @@ obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
SyscallReturn
closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
- int fd = p->sim_fd(xc->getSyscallArg(0));
- return close(fd);
+ int target_fd = xc->getSyscallArg(0);
+ int status = close(p->sim_fd(target_fd));
+ if (status >= 0)
+ p->free_fd(target_fd);
+ return status;
}