--- b.c.orig Wed Apr 11 17:10:49 2001 +++ b.c Sat Apr 21 23:11:38 2001 @@ -16,6 +16,9 @@ #include #endif #include +#include +#include +#include #include #include #include @@ -178,6 +181,7 @@ else b->o = pdefault; mset (b->marks, 0, sizeof (b->marks)); + b->filehandle = -1; /* initialize filehandle &&& ob */ b->rdonly = 0; b->orphan = 0; b->oldcur = 0; @@ -229,6 +233,11 @@ void brm (B *b) { if (b && !--b->count) { + if (b->filehandle != -1) { + /* close filehandle, free lock &&& ob */ + close (b->filehandle); + } + if (b->changed) abrerr (b->name); if (b == errbuf) @@ -1867,7 +1876,8 @@ B *b; long skip, amnt; char *n; - int nowrite = 0; + struct stat sb; + int nowrite = 0, fh = -1; if (!s || !s[0]) { @@ -1920,6 +1930,14 @@ goto opnerr; } + /* Lock the file &&& ob,petef */ + if (fi) + { + fh = dup( fileno(fi) ); + nowrite = (flock (fh, LOCK_EX | LOCK_NB)); + } + + /* Skip data if we need to */ if (skip && lseek (fileno (fi), skip, 0) < 0) { @@ -1978,6 +1996,8 @@ vsrm (n); b->er = error; + if (fh != -1) + b->filehandle = fh; return b; }