Sun Feb 24 11:09:06 2013: Request 33513 was acted upon. Transaction: Correspondence added by LSTEVENS Queue: Win32-Console Subject: Handle to std channel broken by the DESTROY method of Win32::Console Broken in: (no value) Severity: (no value) Owner: Nobody Requestors: yon.ar.ch...@gmail.com Status: open Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=33513 >
This issue also causes problems with the use of threads. If a Win32::Console object exists and a thread is then joined (or detached) the cloned Win32::Console object in the thread calls the DESTROY method and renders the Console unuseable thereafter. The following snippet illustrates; again the "Hello" is not displayed. _CODE_BEGIN_ use threads; use Win32::Console; Win32::Console->new(Win32::Console::STD_OUTPUT_HANDLE()); $myThread = threads->create( sub { return } ); $myThread->join(); print "Hello\n"; _CODE_END_ I'm using: Perl version : ActivePerl v5.12.3 (MSWin32-x86-multi-thread), build 1204 OS : Microsoft Windows XP Professional Module version : Win32::Console 0.09 I had initally fixed this by inserting this line in Console.pm, just before sub AUTOLOAD: sub CLONE_SKIP { 1 } # Make module thread safe by not cloning it into child threads This ensures that the DESTROY method is only called once per object (and not every time a clone of the object is destroyed in a thread). In fact what this does is that it prevents any cloning of Win32::Console into child threads, which works for me. However the fix suggested in this bug report by Richard Burkert also fixes the problem and is more general. This bug report was raised on module version 0.07 five years ago and now we are on 0.09. Any chance this can be fixed in a new version ? Thanks