By the way, this should cancel the alarm() after the fcntl().... > > fd = open(RUN, O_CREAT) > if (fd < 0) > error > > struct flock fl; > fl.l_type = FWRLCK; > fl.l_whence = 0; > fl.l_start = 0; > fl.l_len = 0; > alarm(5); /* or however many seconds you want to wait */ > if (fcntl(fd, F_SETLKW, &fl) == -1) { > if (errno == EINTR) /* timed out */ > else /* other error */ > } alarm(0)