[Issue 16475] New: Unloading Shared Library Closes stdout File Handle.

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Sep 7 12:31:16 PDT 2016


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 at puremagic.com
          Reporter: gyroheli at 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

--


More information about the Digitalmars-d-bugs mailing list