diff --git a/src/system/kernel/fs/fd.c b/src/system/kernel/fs/fd.c index 4a50ed194e..3e1c5059d0 100644 --- a/src/system/kernel/fs/fd.c +++ b/src/system/kernel/fs/fd.c @@ -242,6 +242,9 @@ dup2_fd(int oldfd, int newfd, bool kernel) atomic_add(&context->fds[oldfd]->ref_count, 1); atomic_add(&context->fds[oldfd]->open_count, 1); context->fds[newfd] = context->fds[oldfd]; + + if (evicted == NULL) + context->num_used_fds++; } mutex_unlock(&context->io_mutex); diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index cd341c875d..7849440b6f 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -2903,6 +2903,7 @@ vfs_new_io_context(void *_parentContext) if (descriptor != NULL && (descriptor->open_mode & O_CLOEXEC) == 0) { context->fds[i] = descriptor; + context->num_used_fds++; atomic_add(&descriptor->ref_count, 1); atomic_add(&descriptor->open_count, 1); }