Kill script from outside script

3 views (last 30 days)
Jnior
Jnior on 26 Jul 2012
Hi all
I have the following problem. I start a Matlab exe-file (from matlab compiler), which creates a place holder function. That function then waits for input and when it gets it, it starts a script inside it. The reason I do it this way is that it takes a long time to start matlab before the actual execution can start if I don't, and I want the script to run as soon as the input arrives. Now, I want to be able to stop the "inner" script without killing the place holder function. Can I do that, and in that case, how?
I can't litter the code with error conditions because I might want to kill the process when it's doing a long loop in a function I don't have access to.
If that's not possible, is there any other way of speeding up the startup in matlab compiler .exe files?

Answers (1)

Sumit Tandon
Sumit Tandon on 26 Jul 2012
Have you considered using a combination of flags (being set by external inputs) and break/continue statements?
Before starting the EXE created using MATLAB Compiler, MCR needs to be started in the background. MCR is a head-less version of MATLAB. The start-up time for MCR is going to be similar to MATLAB.
  2 Comments
Jnior
Jnior on 26 Jul 2012
Thank you for the quick answer.
Yes, I have considered flags, the problem is that many time consuming parts of the code is made inside code that I haven't written, and while I could technically create a copy of the entire matlab library with little edits, it seems a bit... Inelegant. There's also quite a lot of code, some of which I have not written myself and it would be a hassle to go through everything to fix all the places that might take time.
Is there any other way to open the MCR before the actual execution starts in a way that doesn't require it to open again every time you want to use it?
Sumit Tandon
Sumit Tandon on 26 Jul 2012
Unfortunately there is no way to start the MCR before the EXE - since its "in-process" MCR. You cannot start the MCR as a background process and then start the EXE. You will need to start the EXE (together with MCR) and then wait for the input to come, just like you are doing now.

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!