ndbreopen does not close the old file descriptor. Reference: /n/patches.lsub.org/patch/ndbreopen.1 Date: Fri Jun 29 18:49:51 CES 2012 Signed-off-by: esoriano@lsub.org --- /sys/src/libndb/ndbopen.c Thu Apr 12 12:26:24 2012 +++ /sys/src/libndb/ndbopen.c Fri Jun 29 18:23:21 2012 @@ -70,6 +70,7 @@ if(db == 0) return 0; memset(db, 0, sizeof(Ndb)); + db->b.fid = -1; strncpy(db->file, file, sizeof(db->file)-1); if(ndbreopen(db) < 0){ @@ -89,11 +90,13 @@ int fd; Dir *d; + if(Bfildes(&db->b) >= 0) + close(Bfildes(&db->b)); + /* forget what we know about the open files */ if(db->mtime){ _ndbcacheflush(db); hffree(db); - close(Bfildes(&db->b)); Bterm(&db->b); db->mtime = 0; }