Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

Error shutting down TCL


Hi,

I'm having some trouble shutting down TCL embedded in a DLL (on
WinXP). The function below blows up on the second printf. For some
reason after calling Tcl_Finalize, I always get the error "Library
function error(return value == -1 {0xffffffff}). Bad File Handle

If I comment out the printf... I still get the same error on the very
next printf I encounter

int __stdcall ShutDown(void) {

        int ret;

        ret = printf ("Deleting instance of TCL Interpreter\n");
        Tcl_DeleteInterp(myInterpreter);
        Tcl_Finalize();

        ret = printf("Unloading TCL Library: %#X\n", hTCLModule);
        FreeLibrary(hTCLModule);
        return 0;

}

Jon
On May 31, 2:28 pm, bluemoosek@gmail.com wrote:

One of the things Tcl_Finalize does is closing open channels
(including stdin and stdout) This means that after a call to
Tcl_Finalize these channels are not available anymore and therefore a
printf will fail.

You could move the printf line to above the Tcl_Finalize.

Mark

Mark Janssen schrieb:

> One of the things Tcl_Finalize does is closing open channels
> (including stdin and stdout) This means that after a call to
> Tcl_Finalize these channels are not available anymore and therefore a
> printf will fail.

Is closing the standard channels a good thing? Maybe (as in this
example) the user wants to do something more after finalizing Tcl...
and standard channels get closed on exit() anyway.
Mark Janssen schrieb:

> One of the things Tcl_Finalize does is closing open channels
> (including stdin and stdout) This means that after a call to
> Tcl_Finalize these channels are not available anymore and therefore a
> printf will fail.

Well, not exactly. In fact the Tcl IO subsystem does everything to
NOT accidentally close the stdio. But Tcl_Finalize() also calls
registered exit handlers of other Tcl extensions which may close open
file handles too.

As I stumbled upon this behavior myself: if you have Expect included,
it shoots down everything that looks like an open file handle,
including stdio.

The only one thing that reliably worked for me was to dup() the stdio
before Tcl_Finalize() and use the dup()ed file handles together with
fprintf().

kind regards
--
Matthias Kraft
Software AG, Germany

On Jun 1, 8:15 am, Matthias Kraft

<Matthias.Kr@nospam.softwareag.com> wrote:
> Mark Janssen schrieb:

> The only one thing that reliably worked for me was to dup() the stdio
> before Tcl_Finalize() and use the dup()ed file handles together with
> fprintf().

> kind regards
> --
> Matthias Kraft
> Software AG, Germany

Is dup'ing the stdout even possible in Windows? How do I do that?
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc