-static bool
-kill_pidfile(const char *pidfile, FILE *file)
-{
- char line[128];
- struct flock lck;
-
- lck.l_type = F_WRLCK;
- lck.l_whence = SEEK_SET;
- lck.l_start = 0;
- lck.l_len = 0;
- if (fcntl(fileno(file), F_GETLK, &lck)) {
- cond_error(errno, "%s: fcntl", pidfile);
- return false;
- }
-
- if (!fgets(line, sizeof line, file)) {
- cond_error(errno, "%s: read", pidfile);
- return false;
- }
-
- if (lck.l_pid != strtoul(line, NULL, 10)) {
- cond_error(errno, "l_pid (%ld) != %s pid (%s)",
- (long int) lck.l_pid, pidfile, line);
- return false;
- }
-
- if (kill(lck.l_pid, sig_nr) < 0) {
- cond_error(errno, "%s: kill(%ld)", pidfile, (long int) lck.l_pid);
- return false;
- }
-
- return true;
-}
-