pidfile: fix fd leak from pidfile_remove()

CID 717081: Resource leak (RESOURCE_LEAK)
At (10): Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2012-09-28 07:04:06 -07:00
parent 687d6d58f1
commit 98da9f9b8c

View File

@ -82,9 +82,9 @@ int pidfile_remove(void)
char buf[32];
memset(buf, 0, sizeof(buf));
ssize_t res = safe_read(fd, buf, sizeof(buf));
TEMP_FAILURE_RETRY(::close(fd));
if (res < 0)
return res;
TEMP_FAILURE_RETRY(::close(fd));
int a = atoi(buf);
if (a != getpid())
return -EDOM;