digitalmars.D.bugs - [Issue 16475] New: Unloading Shared Library Closes stdout File Handle.
- via Digitalmars-d-bugs (28/28) Sep 07 2016 https://issues.dlang.org/show_bug.cgi?id=16475
https://issues.dlang.org/show_bug.cgi?id=16475 Issue ID: 16475 Summary: Unloading Shared Library Closes stdout File Handle. Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: gyroheli gmail.com Created attachment 1613 --> https://issues.dlang.org/attachment.cgi?id=1613&action=edit assembly If you load and unload a shared library with DMD on windows using Runtime.loadLibrary and unloadLibrary. This causes the stdout file handles to be closed. It seems the issue is with the function that calls DllMain, when it detaches from process it calls the C function "exit()" which in turn closes the file handles. import core.runtime; import std.stdio; void* library = Runtime.loadLibrary("myDlib.dll"); Runtime.unloadLibrary(library); writeln("hello"); stdout.flush(); // fails errno 9, bad file number --
Sep 07 2016