Discussion:
forrtl: error (200): program aborting due to control-C event
(too old to reply)
David Marshburn
2009-05-12 22:48:02 UTC
Permalink
i have used the matlab compiler (R2008b) to make a shared library (.dll) of some of my matlab code. when i link with this library in a c++ program, my interrupt handler is disregarded, and the following statement is printed before program termination:

forrtl: error (200): program aborting due to control-C event

web searches suggest that this messages indicates that a fortran library is catching the SIGINT event, and i can easily imagine that, somewhere in the matlab i've linked in, there is some fortran code.

has anyone run into this problem before? there are few-to-no results for "forrtl" posts in the newsgroup. is there any way to override this behavior so that my interrupt handler can catch it (and so that mclTerminateApplication() etc. can be called correctly and other program termination code can happen).

thanks!

-david
David Marshburn
2009-05-12 23:04:02 UTC
Permalink
i should also note that this program runs without an interface/GUI, so the standard tricks of making a "quit" button or of catching window-close events don't work in this case. i'd still want to catch ctrl-c, though, or, at least, disable the fortran code from catching it.
Shaf
2009-08-17 20:15:20 UTC
Permalink
David,

How are you setting up your ctrl-c handler? It's also important that you set it up after mclInitializaApplication and <lib>Initialize has been called. The fortran runtime provides it's own ctrl-c handler which is installed as part of MCR init. However as long as you install your handler after the MCR and library has been initialized it should work. I have used SetConsoleCtrlHandler to do this.

http://msdn.microsoft.com/en-us/library/ms686016%28VS.85%29.aspx

You will need to use a visual studio compiler for this.

Thanks,
Shaf
Post by David Marshburn
i should also note that this program runs without an interface/GUI, so the standard tricks of making a "quit" button or of catching window-close events don't work in this case. i'd still want to catch ctrl-c, though, or, at least, disable the fortran code from catching it.
David Marshburn
2009-08-18 21:55:19 UTC
Permalink
thanks for the reply, shaf!

i'm just using signal to catch SIGINT. the handler is set up after all the MCR init stuff.

it turned out that the answer was that we weren't waiting long enough for the MCR initialization to complete. it was unexpected that the initialization took on the order of a minute or more. when we terminated things early, we got a surprising fortran signal handling!
Post by Shaf
David,
How are you setting up your ctrl-c handler? It's also important that you set it up after mclInitializaApplication and <lib>Initialize has been called. The fortran runtime provides it's own ctrl-c handler which is installed as part of MCR init. However as long as you install your handler after the MCR and library has been initialized it should work. I have used SetConsoleCtrlHandler to do this.
http://msdn.microsoft.com/en-us/library/ms686016%28VS.85%29.aspx
You will need to use a visual studio compiler for this.
Thanks,
Shaf
Post by David Marshburn
i should also note that this program runs without an interface/GUI, so the standard tricks of making a "quit" button or of catching window-close events don't work in this case. i'd still want to catch ctrl-c, though, or, at least, disable the fortran code from catching it.
b***@gmail.com
2018-01-24 13:05:40 UTC
Permalink
I had the same issue and worked around it with SetConsoleCtrlHandler as you said.
However, I wanted to add that it only works for me if I call SetConsoleCtrlHandler AFTER calling a function in the dll, not just the MCR, App and dll init functions.
hb kashu
2014-05-01 07:47:54 UTC
Permalink
Hi David?

I have encounter something like you, when I click 'close ' on the top right corner of the C++ win32 console form, it trigger unexpected breakpoint an print 'forrtl: error (200): program aborting due to windows-CLOSE event'...

Can you please details your solution?

Thanks you very much!

Zhishang.
Post by David Marshburn
forrtl: error (200): program aborting due to control-C event
web searches suggest that this messages indicates that a fortran library is catching the SIGINT event, and i can easily imagine that, somewhere in the matlab i've linked in, there is some fortran code.
has anyone run into this problem before? there are few-to-no results for "forrtl" posts in the newsgroup. is there any way to override this behavior so that my interrupt handler can catch it (and so that mclTerminateApplication() etc. can be called correctly and other program termination code can happen).
thanks!
-david
Loading...