cxxrtl: fix close of invalid fd in spool destructor.

This commit is contained in:
Catherine 2024-05-08 00:27:28 +00:00
parent ce45011275
commit 7294d8b5af
1 changed files with 3 additions and 2 deletions

View File

@ -512,9 +512,10 @@ public:
spool &operator=(const spool &) = delete;
~spool() {
if (int fd = writefd.exchange(-1))
int fd;
if ((fd = writefd.exchange(-1)) != -1)
close(fd);
if (int fd = readfd.exchange(-1))
if ((fd = readfd.exchange(-1)) != -1)
close(fd);
}