[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] Re: multipath tools racy on RUN file.



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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]