diff options
| author | Russ White <russ@riw.us> | 2018-09-24 10:47:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-24 10:47:38 -0400 |
| commit | 97cedbcc4e2aada5675f5df1f59acb6b2cf931bb (patch) | |
| tree | a50465f78094f1946003638c6c8836658828ed32 | |
| parent | b4016740467cd33c802233200116ef72446993bc (diff) | |
| parent | 8c5ff531a1532aaf507eaafb3b1219c312f93a05 (diff) | |
Merge pull request #3073 from donaldsharp/pid_cleanup
Pid cleanup
| -rw-r--r-- | lib/libfrr.c | 31 | ||||
| -rw-r--r-- | lib/pid_output.c | 2 |
2 files changed, 1 insertions, 32 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c index 69e6882617..2bce4766d3 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -262,34 +262,6 @@ bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len, static struct frr_daemon_info *di = NULL; -static void frr_guard_daemon(void) -{ - int fd; - struct flock lock; - const char *path = di->pid_file; - - fd = open(path, O_RDWR); - if (fd != -1) { - memset(&lock, 0, sizeof(lock)); - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - if (fcntl(fd, F_GETLK, &lock) < 0) { - flog_err_sys( - EC_LIB_SYSTEM_CALL, - "Could not do F_GETLK pid_file %s (%s), exiting", - path, safe_strerror(errno)); - exit(1); - } else if (lock.l_type == F_WRLCK) { - flog_err_sys( - EC_LIB_SYSTEM_CALL, - "Process %d has a write lock on file %s already! Error: (%s)", - lock.l_pid, path, safe_strerror(errno)); - exit(1); - } - close(fd); - } -} - void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv) { di = daemon; @@ -619,9 +591,6 @@ struct thread_master *frr_init(void) zprivs_init(di->privs); - /* Guard to prevent a second instance of this daemon */ - frr_guard_daemon(); - master = thread_master_create(NULL); signal_init(master, di->n_signals, di->signals); diff --git a/lib/pid_output.c b/lib/pid_output.c index b0643c4fe2..f5f7b1d171 100644 --- a/lib/pid_output.c +++ b/lib/pid_output.c @@ -60,7 +60,7 @@ pid_t pid_output(const char *path) if (fcntl(fd, F_SETLK, &lock) < 0) { flog_err_sys(EC_LIB_SYSTEM_CALL, - "Could not lock pid_file %s (%s), exiting", + "Could not lock pid_file %s (%s), exiting. Please ensure that the daemon is not already running", path, safe_strerror(errno)); exit(1); } |
