|
|
ad6487 |
diff -up cronie-1.4.11/src/misc.c.ddd cronie-1.4.11/src/misc.c
|
|
|
ad6487 |
--- cronie-1.4.11/src/misc.c.ddd 2013-07-18 14:27:08.000000000 +0200
|
|
|
ad6487 |
+++ cronie-1.4.11/src/misc.c 2013-08-30 13:51:22.227040980 +0200
|
|
|
ad6487 |
@@ -75,7 +75,9 @@ static int LogFD = ERR;
|
|
|
ad6487 |
static int syslog_open = FALSE;
|
|
|
ad6487 |
#endif
|
|
|
ad6487 |
|
|
|
ad6487 |
-#if defined(HAVE_FCNTL) && defined(F_SETLK)
|
|
|
ad6487 |
+#if defined(HAVE_FLOCK)
|
|
|
ad6487 |
+# define trylock_file(fd) flock((fd), LOCK_EX|LOCK_NB)
|
|
|
ad6487 |
+#elif defined(HAVE_FCNTL) && defined(F_SETLK)
|
|
|
ad6487 |
static int trylock_file(int fd) {
|
|
|
ad6487 |
struct flock fl;
|
|
|
ad6487 |
|
|
|
ad6487 |
@@ -89,8 +91,6 @@ static int trylock_file(int fd) {
|
|
|
ad6487 |
}
|
|
|
ad6487 |
#elif defined(HAVE_LOCKF)
|
|
|
ad6487 |
# define trylock_file(fd) lockf((fd), F_TLOCK, 0)
|
|
|
ad6487 |
-#elif defined(HAVE_FLOCK)
|
|
|
ad6487 |
-# define trylock_file(fd) flock((fd), LOCK_EX|LOCK_NB)
|
|
|
ad6487 |
#endif
|
|
|
ad6487 |
|
|
|
ad6487 |
/*
|
|
|
ad6487 |
@@ -346,6 +346,14 @@ void acquire_daemonlock(int closeflag) {
|
|
|
ad6487 |
(void) fcntl(fd, F_SETFD, 1);
|
|
|
ad6487 |
}
|
|
|
ad6487 |
|
|
|
ad6487 |
+#if !defined(HAVE_FLOCK)
|
|
|
ad6487 |
+ else {
|
|
|
ad6487 |
+ /* Racy but better than nothing, just hope the parent exits */
|
|
|
ad6487 |
+ sleep(0);
|
|
|
ad6487 |
+ trylock_file(fd);
|
|
|
ad6487 |
+ }
|
|
|
ad6487 |
+#endif
|
|
|
ad6487 |
+
|
|
|
ad6487 |
sprintf(buf, "%ld\n", (long) pid);
|
|
|
ad6487 |
(void) lseek(fd, (off_t) 0, SEEK_SET);
|
|
|
ad6487 |
len = strlen(buf);
|