tdo not depend on flock - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit c71af67adc9946fe2a560259f5e79174dfa07e8d | |
parent 9e863cf5617925a7f7e855207e56f94fc72a662e | |
Author: rsc | |
Date: Fri, 7 Jan 2005 07:19:35 +0000 do not depend on flock Diffstat: M src/lib9/open.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- | |
diff --git a/src/lib9/open.c b/src/lib9/open.c | |
t@@ -12,6 +12,7 @@ p9open(char *name, int mode) { int cexec, rclose; int fd, umode, lock, rdwr; + struct flock fl; rdwr = mode&3; umode = rdwr; t@@ -34,7 +35,11 @@ p9open(char *name, int mode) fd = open(name, umode); if(fd >= 0){ if(lock){ - if(flock(fd, (rdwr==OREAD) ? LOCK_SH : LOCK_EX) < 0){ + fl.l_type = (rdwr==OREAD) ? F_RDLCK : F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; + if(fcntl(fd, F_SETLK, &fl) < 0){ close(fd); return -1; } |