Skip to content

Commit

Permalink
Add check for orphaned file descriptor.
Browse files Browse the repository at this point in the history
A user reported that the CPU was 80 -> 100%. An orphaned
fd is certainly one possibility and this will highlight
it.
  • Loading branch information
banksy-git committed Feb 22, 2021
1 parent 152494a commit fa520f9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gateway/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ int main(int argc, char** argv)
_error_exit("write serial");
}
}
} else {
fprintf(stderr, "Bug: Closing orphaned fd %d.\n", i);
close(i);
FD_CLR(i, &_master_read_set);
}

}
Expand Down

0 comments on commit fa520f9

Please sign in to comment.