use write() instead of close() to avoid hang on Minix.