flock($f, LOCK_EX);
fwrite($f, $err);
flock($f, LOCK_UN);