[Ecls-list] Patch to prevent crash on Windows GUI applications

Goffioul Michael goffioul at imec.be
Mon Aug 29 00:39:23 UTC 2005


I also had that problem when integrating ECL in MATLAB, however I
solved it in a LISP programmatical way: during the initialization of
my module, I redefined *terminal-io* and *error-output* streams
(all other standard streams are somehow linked to those 2 streams).

The only problem left was related to ext::run-program which duplicates
standard handles to pass them to the child process, but this part
have been solved partially.

Regarding your proposal, I don't like the idea of having a console
window opening in *all* cases without controlling possibilities. I
would go for a more flexible solution where the developper could
say "do not open a console and redirect standard streams to nowhere".
At least in my case, I don't want to see a console opening in my
MATLAB integration.

Michael.


> Hi,
> 
> I'm working on a plugin for a Windows application and I 
> noticed there is
> a problem when creating a GUI application because the stdin, 
> stdout and
> stderr streams are invalid and ECL tries to use them.
> Based on what I've seen done in GambitC to solve this problem 
> I propose
> this patch to the file src/c/file.d after the variable 
> initialization in
> init_file():
> 
> void
> init_file(void)
> {
> 	cl_object standard_input;
> 	cl_object standard_output;
> 	cl_object error_output;
> 	cl_object standard;
> 	cl_object x;
> //----- this is the new code -----------------
> #if defined(_MSC_VER) || defined(mingw32)
>   HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE);
>   if (GetFileType (h) == FILE_TYPE_UNKNOWN)
>   {
>     AllocConsole();
>     freopen("CONOUT$", "a", stdout);
>     freopen("CONIN$", "r", stdin);
>   }
> #endif
> //--------------------------------------------
> .....
> 
> Basically in GUI mode the handles to stdout, stdin and stderr 
> are of an
> invalid type. The code will then create a console and 
> redirect input and
> output to the newly created console allowing user interaction (like
> debugging). The stderr by default is sent to stdout in console.
> Any console version of a program won't be affected by this 
> patch and it
> would work like before.
> 
> Thanks,
> Dan Hristodorescu.
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development 
> Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * 
> Testing & QA
> Security * Process Improvement & Measurement * 
http://www.sqe.com/bsce5sf
_______________________________________________
Ecls-list mailing list
Ecls-list at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list




More information about the ecl-devel mailing list