Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ static int set_procfs_val(const char *path, const char *val)
static int do_status(int type)
{
pid_t pid;
int rv, lock_fd, ret;
int rv, status_lock_fd, ret;
const char *reason = NULL;
char lockfile_data[1024], *cp;

Expand All @@ -1292,33 +1292,31 @@ static int do_status(int type)
}


rv = _lockfile(O_RDWR, &lock_fd, &pid);
if (rv == 0) {
reason = "PID file not locked.";
rv = _lockfile(O_RDWR, &status_lock_fd, &pid);
if (status_lock_fd == -1) {
reason = "No PID file.";
goto quit;
}
if (lock_fd == -1) {
reason = "No PID file.";
if (rv == 0) {
close(status_lock_fd);
reason = "PID file not locked.";
goto quit;
}

if (pid) {
fprintf(stdout, "booth_lockpid=%d ", pid);
fflush(stdout);
}


rv = read(lock_fd, lockfile_data, sizeof(lockfile_data) - 1);
rv = read(status_lock_fd, lockfile_data, sizeof(lockfile_data) - 1);
if (rv < 4) {
close(status_lock_fd);
reason = "Cannot read lockfile data.";
ret = PCMK_LSB_UNKNOWN_ERROR;
goto quit;

}
lockfile_data[rv] = 0;

if (lock_fd != -1)
close(lock_fd);
close(status_lock_fd);


/* Make sure it's only a single line */
Expand Down