diff options
Diffstat (limited to 'libebtc.c')
-rw-r--r-- | libebtc.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -143,10 +143,16 @@ int use_lockfd; * or -2 on any other error. */ static int lock_file() { - int fd = open(LOCKFILE, O_CREAT, 00600); - - if (fd < 0) - return -2; + int fd, try = 0; + +retry: + fd = open(LOCKFILE, O_CREAT, 00600); + if (fd < 0) { + if (try == 1 || mkdir(LOCKDIR, 00700)) + return -2; + try = 1; + goto retry; + } return flock(fd, LOCK_EX); } |