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