Add .gitignore
Improve fdopen; document it