Frage

If I am writing a Perl script that overwrites STDERR with a duplicate of STDOUT but I never restore the filehandle, what happens at the end of script execution? I can't find anything that warns against what actually occurs or doesn't occur.

I'm probably misinformed but thanks for your patience.

War es hilfreich?

Lösung

When a process exits, the kernel recovers all used resources. This includes all the file descriptors, which are simply closed. If there is an application-level buffer, data in that buffer may not have been written to the kernel, but otherwise there is no risk in keeping file descriptors open before exiting.

If your Perl script ends by using exec to launch another process, that process will inherit all the file descriptors (except those marked as close on exec).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top