Fix minor issues in pidfile_read() and pidfile_signal(), caught by Coverity

- Simplify pidfile_read(), no need to call access() when fopen() is more
  than capable of failing on its own if we do not have READ access.
- The remove() syscall requires that you check the return value, but we
  don't care about that when having signalled a TERM signal to a process.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-07-09 01:59:10 +02:00
parent 5a50a6add1
commit c2d0ed0d12
+1 -5
View File
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
extern char *chomp(char *str);
@@ -46,9 +45,6 @@ int pidfile_read(const char *pidfile)
return -1;
}
if (access(pidfile, F_OK) < 0)
return -1;
fp = fopen(pidfile, "r");
if (!fp)
return -1;
@@ -89,7 +85,7 @@ int pidfile_signal(const char *pidfile, int signal)
ret = kill(pid, signal);
if ((ret == -1) || (signal == SIGTERM) || (signal == SIGKILL))
remove(pidfile);
(void)remove(pidfile);
return 0;
}