CWE-404 / https://cwe.mitre.org/data/definitions/404.html
if (pid_fd < 0)
return pid_fd;
- if (read(pid_fd, pid_str, sizeof(pid_str)) <= 0)
+ if (read(pid_fd, pid_str, sizeof(pid_str)) <= 0) {
+ close(pid_fd);
return -1;
+ }
pid = atoi(pid_str);
- if (pid <= 0)
+ if (pid <= 0) {
+ close(pid_fd);
return -1;
+ }
/* another running process that we can signal COULD be
* a competing rrdcached */
/*FALLTHRU*/
error:
remove_pidfile();
+ close(pid_fd);
return -1;
} /* }}} int daemonize */