Don't call close(2) more than once

Don't call close(2) more then once, even though close(2) returns -1.

See the manual page for details.
This commit is contained in:
Changli Gao 2019-12-21 23:24:28 +08:00
parent 1b7d541431
commit a35e612c55

View File

@ -374,7 +374,7 @@ struct FileDescriptor {
explicit FileDescriptor(int fd) : fd_(fd) {}
~FileDescriptor() {
if (fd_ >= 0) {
NO_INTR(close(fd_));
close(fd_);
}
}
int get() { return fd_; }