aboutsummaryrefslogtreecommitdiff
path: root/fesvr/syscall.cc
diff options
context:
space:
mode:
Diffstat (limited to 'fesvr/syscall.cc')
-rw-r--r--fesvr/syscall.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/fesvr/syscall.cc b/fesvr/syscall.cc
index 875ffb7..e277be1 100644
--- a/fesvr/syscall.cc
+++ b/fesvr/syscall.cc
@@ -174,9 +174,16 @@ syscall_t::syscall_t(htif_t* htif)
if (stdin_fd < 0 || stdout_fd0 < 0 || stdout_fd1 < 0)
throw std::runtime_error("could not dup stdin/stdout");
- fds.alloc(stdin_fd); // stdin -> stdin
- fds.alloc(stdout_fd0); // stdout -> stdout
- fds.alloc(stdout_fd1); // stderr -> stdout
+ fds_index.push_back(fds.alloc(stdin_fd)); // stdin -> stdin
+ fds_index.push_back(fds.alloc(stdout_fd0)); // stdout -> stdout
+ fds_index.push_back(fds.alloc(stdout_fd1)); // stderr -> stdout
+}
+
+syscall_t::~syscall_t() {
+ for (auto i: fds_index) {
+ close(fds.lookup(i));
+ fds.dealloc(i);
+ }
}
std::string syscall_t::do_chroot(const char* fn)