[dm-devel] Re: multipath tools racy on RUN file.
Dave Olien
dmo at osdl.org
Mon Oct 18 23:52:51 UTC 2004
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)
More information about the dm-devel
mailing list