From: mmj Date: Thu, 13 Jan 2005 08:57:32 +0000 (+1100) Subject: Let's spin until fcntl does not return EINTR due to a signal. X-Git-Tag: RELEASE_1_2_0~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad42e20fd2d211f0131e707897ba919602e8869c;p=thirdparty%2Fmlmmj.git Let's spin until fcntl does not return EINTR due to a signal. --- mylocking.c 16 Jun 2004 21:11:54 -0000 1.3 +++ mylocking.c 13 Jan 2005 08:56:24 -0000 @@ -34,7 +34,9 @@ locktype.l_whence = SEEK_SET; locktype.l_start = 0; locktype.l_len = 0; - mylock = fcntl(fd, F_SETLKW, &locktype); + do { + mylock = fcntl(fd, F_SETLKW, &locktype); + while(mylock < 0 && errno == EINTR); return mylock; } @@ -45,7 +47,9 @@ struct flock locktype; locktype.l_type = F_UNLCK; - myunlock = fcntl(fd, F_SETLKW, &locktype); + do { + myunlock = fcntl(fd, F_SETLKW, &locktype); + while(myunlock < 0 && errno == EINTR) return myunlock; } --- diff --git a/src/mylocking.c b/src/mylocking.c index 82353df3..2d25f9c9 100644 --- a/src/mylocking.c +++ b/src/mylocking.c @@ -34,7 +34,9 @@ int myexcllock(int fd) locktype.l_whence = SEEK_SET; locktype.l_start = 0; locktype.l_len = 0; - mylock = fcntl(fd, F_SETLKW, &locktype); + do { + mylock = fcntl(fd, F_SETLKW, &locktype); + while(mylock < 0 && errno == EINTR); return mylock; } @@ -45,7 +47,9 @@ int myunlock(int fd) struct flock locktype; locktype.l_type = F_UNLCK; - myunlock = fcntl(fd, F_SETLKW, &locktype); + do { + myunlock = fcntl(fd, F_SETLKW, &locktype); + while(myunlock < 0 && errno == EINTR) return myunlock; }