Check for error in fcntl, as we depend on close-on-exec, F_SETFD will result in -1 in case of error (stored in errno). To not have a follow-up warning about not freeing filename, move up. This commit was SVN r21171.