use STDERR_FILENO instead of 2