fclose closes an open file resource, releasing it from memory and any write-locks on the file.
Calling fclose() here after dup()ing its file descriptor blocks until the child process has ended (presumably because the stream …