mirror of
https://github.com/troglobit/libite.git
synced 2026-11-27 20:38:26 +00: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 parent
5a50a6add1
commit
c2d0ed0d12
1 file changed
+1
-5
+1
-5
@@ -19,7 +19,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern char *chomp(char *str);
|
extern char *chomp(char *str);
|
||||||
|
|
||||||
@@ -46,9 +45,6 @@ int pidfile_read(const char *pidfile)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access(pidfile, F_OK) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
fp = fopen(pidfile, "r");
|
fp = fopen(pidfile, "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -89,7 +85,7 @@ int pidfile_signal(const char *pidfile, int signal)
|
|||||||
|
|
||||||
ret = kill(pid, signal);
|
ret = kill(pid, signal);
|
||||||
if ((ret == -1) || (signal == SIGTERM) || (signal == SIGKILL))
|
if ((ret == -1) || (signal == SIGTERM) || (signal == SIGKILL))
|
||||||
remove(pidfile);
|
(void)remove(pidfile);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user