dd: Check result of close(2) for errors

close(2) can return errors from previous operations which should not be ignored.

PR: 229616
Submitted by:	Thomas Hurst
Reported by:	Thomas Hurst
Reviewed by:	mmacy@
Obtained from:	Ryan Moeller
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21376
This commit is contained in:
Matt Macy 2019-09-30 21:53:26 +00:00
parent 3b96efbda0
commit 2048fe7098

View File

@ -124,7 +124,8 @@ main(int argc __unused, char *argv[])
* descriptor explicitly so that the summary handler (called
* from an atexit() hook) includes this work.
*/
close(out.fd);
if (close(out.fd) == -1 && errno != EINTR)
err(1, "close");
exit(0);
}