mirror of
https://github.com/troglobit/libite.git
synced 2026-10-06 23:40:05 +07:00
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:
+1
-5
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user