divide writing from reading
enable O_NONBLOCK
write to stdout in a thread