Can I make MATLAB stop working after a user presses Control-C?

I run MATLAB (command line version) from a shell script, and I would like it to save the shell behavior, if it is clicked Ctrl, Cit ends. But instead, he wants to maintain control of the terminal, and I (or my poor users after me) should dial quit(1)to get him to go out and tell the shell that it failed.

You can't intercept Ctrl- Cwith the try/ catch... block of any other ideas? Anything I could do on the shell side to intercept keystrokes before they hit MATLAB?

onCleanupseems like an option, but then I have to turn the entire script function into a function (this is already a dynamically generated thing try/ catchin a Makefile). But if this is the only thing that works, then I will do it ...

+3
source share
2 answers

Use onCleanup:

I wanted to do the same, but after I read this thread , I used onCleanup . My problem was that I had a server in Matlab, that when I press CTRL + C it will be saved listenon the port on which it was launched → the second start, I would get an error bind.

+1
source

You can try:

stty quit ^C

matlab, .

0

Source: https://habr.com/ru/post/1769813/


All Articles