file locking with flock(), plus error return from Sync().