- } else {
- /*
- * Abort locking, if we fail to lock after 5 attempts
- * and are never able to stat the lock file. Or, if
- * we can stat the lockfile but exceed LOCK_RETRIES
- * seconds waiting for it (by falling out of the loop).
- */
- struct stat st;
- if (stat (lkinfo.curlock, &st) == -1) {
- if (i++ > 5) break;
- sleep (1);
- } else {
- time_t curtime;
- time (&curtime);
-
- /* check for stale lockfile, else sleep */
- if (curtime > st.st_ctime + RSECS)
- (void) m_unlink (lkinfo.curlock);
- else
- sleep (1);
- }
- lockname (file, &lkinfo, 1);