There is a potential failure mode that I skipped earlier: you seem to have no way to recover when the file cannot be opened by secondprogram . The problem is not that the file may be locked / incompatible after returning close() , but this other program, completely unrelated to yours, may open the file between close() and system() (say, an AV scanner, someone then grep through the directory containing the file, the backup process). If this happens, the secondprogram will fail, even if your program behaves correctly.
TL / DR: despite the fact that everything works as expected, you should consider the case where the secondprogram may not open the file!
us2012
source share