Mercurial > hg > mlmmj
changeset 399:152504e6be32
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;
}
author | mmj |
---|---|
date | Thu, 13 Jan 2005 19:57:32 +1100 |
parents | 26be35779e13 |
children | 2c03919b9adf |
files | src/mylocking.c |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mylocking.c Tue Dec 14 21:13:21 2004 +1100 +++ b/src/mylocking.c Thu Jan 13 19:57:32 2005 +1100 @@ -34,7 +34,9 @@ locktype.l_whence = SEEK_SET; locktype.l_start = 0; locktype.l_len = 0; + 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; + do { myunlock = fcntl(fd, F_SETLKW, &locktype); + while(myunlock < 0 && errno == EINTR) return myunlock; }