Browse Source

* readable file locking errors

master
Alex 'AdUser' Z 8 years ago
parent
commit
f06984707d
  1. 5
      src/main.c

5
src/main.c

@ -184,7 +184,10 @@ int main(int argc, char *argv[]) {
FILE *pidfile = NULL;
if ((pidfile = fopen(opts.pidfile_path, "w")) != NULL) {
if (flock(fileno(pidfile), LOCK_EX | LOCK_NB) != 0) {
f2b_log_msg(log_error, "can't lock pidfile: %s", strerror(errno));
const char *err = (errno == EWOULDBLOCK)
? "another instance already running"
: strerror(errno);
f2b_log_msg(log_error, "can't lock pidfile: %s", err);
exit(EXIT_FAILURE);
}
fprintf(pidfile, "%d\n", getpid());

Loading…
Cancel
Save