parse_chapter(source, ...);
close(source); // just in case
#ExtremelyBadIdea #fail #IAmAnIdiot

1. I open fd 10
2. I call parse_chapter(10, ...);
3. I close fd 10 inside parse_chapter
4. sqlite3 internally opens a journal file, getting the next available file descriptor (fd 10)
5. I return from the parse_chapter function
6. I close fd 10 "just in case"
7. sqlite3 tries to write to the journal file (fd 10)
8. I complain that sqlite3 must be broken

Man, be careful when you close file descriptors...

#Programming