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:
Mark Johnston 2019-08-07 03:14:45 +00:00
parent a15cb219c6
commit 1966967151
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350671

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);