commit e96f0b9671d12a6977225ea22f7edf455331aa6e
Author: Jan Klemkow <[email protected]>
AuthorDate: Thu Apr 16 22:03:04 2020 +0200
Commit: Jan Klemkow <[email protected]>
CommitDate: Thu Apr 16 22:03:04 2020 +0200
ptty: error handling of close(2)
diff --git a/ptty.c b/ptty.c
index 95adc3c..9d7ee3b 100644
--- a/ptty.c
+++ b/ptty.c
@@ -112,7 +112,8 @@ main(int argc, char *argv[])
die("read:");
if (n == 0) {
pfd[0].fd = -1;
- close(mfd);
+ if (close(mfd) == -1)
+ die("close:");
break;
}
if (write(mfd, buf, n) == -1)
@@ -129,7 +130,8 @@ main(int argc, char *argv[])
if (pfd[0].revents & POLLHUP) {
pfd[0].fd = -1;
- close(mfd);
+ if (close(mfd) == -1)
+ die("close:");
break;
}
if (pfd[1].revents & POLLHUP)