modify flush() implementation on POSIX