test/nstool: Fix fd leak in accept() loop

nstool loops on accept(), but failed to close the accepted socket fds
before continuing on.  So, with repeated commands it would eventually die
with an EMFILE.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2023-05-23 12:25:43 +10:00 committed by Stefano Brivio
parent 527c822a3b
commit e3b19530e4

View file

@ -201,6 +201,8 @@ static void cmd_hold(int argc, char *argv[])
rc = read(afd, &buf, sizeof(buf));
if (rc < 0)
die("read(): %s\n", strerror(errno));
close(afd);
} while (rc == 0);
unlink(sockpath);