Skip to content

Commit

Permalink
sched: increment ref counts in fork()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 28, 2024
1 parent d465dcc commit 36c165c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sched/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ pid_t fork(Thread *t) {
memcpy(p->io, parent->io, sizeof(IODescriptor) * MAX_IO_DESCRIPTORS);
p->iodCount = parent->iodCount;

// increment reference counts for file descriptors
for(int i = 0; i < MAX_IO_DESCRIPTORS; i++) {
if(p->io[i].valid) {
switch(p->io[i].type) {
case IO_FILE:
FileDescriptor *file = p->io[i].data;
file->refCount++;
break;
}
}
}

// clone working directory
strcpy(p->cwd, parent->cwd);

Expand Down

0 comments on commit 36c165c

Please sign in to comment.