readelf: Close input files when done with them.

The low fd limit used by poudriere exposed an odd failure mode in
cap_fileargs (used by readelf as of r350516).  In particular, when
the limit was hit, both the main process and casper service would
block on their shared socket, waiting forever for the other to send a
message.

Reported by:	zeising
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
markj 2019-08-07 03:14:45 +00:00
parent 03ea53cab0
commit 37b420014f

View File

@ -7732,10 +7732,12 @@ main(int argc, char **argv)
for (i = 0; i < argc; i++) {
re->filename = argv[i];
fd = fileargs_open(fa, re->filename);
if (fd < 0)
if (fd < 0) {
warn("open %s failed", re->filename);
else
} else {
dump_object(re, fd);
close(fd);
}
}
exit(EXIT_SUCCESS);