implement flockfile api, rework stdio locking
9 files changed