Search
j0ke.net Open Build Service
>
Projects
>
home:netmax
:
playground
>
ocsync090
> remove_signal.dif
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File remove_signal.dif of Package ocsync090
diff --git a/src/csync_lock.c b/src/csync_lock.c index c64df0a..6a7af95 100644 --- a/src/csync_lock.c +++ b/src/csync_lock.c @@ -29,7 +29,6 @@ #include <errno.h> #include <fcntl.h> -#include <signal.h> #include <stdio.h> #include <string.h> #include <unistd.h> @@ -123,8 +122,9 @@ out: static pid_t _csync_lock_read(CSYNC *ctx, const char *lockfile) { char errbuf[256] = {0}; - char buf[8] = {0}; + char buf[16] = {0}; long int tmp; + struct stat sts; ssize_t rc; int fd; pid_t pid; @@ -165,7 +165,11 @@ static pid_t _csync_lock_read(CSYNC *ctx, const char *lockfile) { pid = (pid_t)(tmp & 0xFFFF); /* Check if process is still alive */ - if (kill(pid, 0) < 0 && errno == ESRCH) { + if (snprintf(buf, sizeof(buf), "/proc/%d", pid) < 0) { + return -1; + } + + if (stat(buf, &sts)== -1 && errno ==ENOENT) { /* Process is dead. Remove stale lock. */ if (unlink(lockfile) < 0) { strerror_r(errno, errbuf, sizeof(errbuf));