Handle a signal: Difference between revisions

Content added Content deleted
(Added MATLAB examples)
m (MATLAB: Fixed works with templates)
Line 533: Line 533:
=={{header|MATLAB}}==
=={{header|MATLAB}}==
MATLAB versions 6.5 (R13) and newer can no longer catch CTRL+C with a try-catch block. The onCleanup() function was introduced in version 7.6 (R2008a), possibly specifically for this situation. However, the designated onCleanup() function will execute no matter how the function ends (task completion, CTRL+C, exception), and CTRL+C will still cause an exception to be thrown and displayed.
MATLAB versions 6.5 (R13) and newer can no longer catch CTRL+C with a try-catch block. The onCleanup() function was introduced in version 7.6 (R2008a), possibly specifically for this situation. However, the designated onCleanup() function will execute no matter how the function ends (task completion, CTRL+C, exception), and CTRL+C will still cause an exception to be thrown and displayed.
{{works with|MATLAB|Version 7.6 (R2008a) and later}}
{{works with|MATLAB|7.6 (R2008a) and later}}
<lang MATLAB>function sigintHandle
<lang MATLAB>function sigintHandle
k = 1;
k = 1;
Line 554: Line 554:
Elapsed time is 3.348772 seconds.
Elapsed time is 3.348772 seconds.
??? Operation terminated by user during ==> sigintHandle at 6</pre>
??? Operation terminated by user during ==> sigintHandle at 6</pre>
{{works with|MATLAB|Version 6.1 (R12.1) and earlier}}
{{works with|MATLAB|6.1 (R12.1) and earlier}}
{{untested|MATLAB}}
{{untested|MATLAB}}
<lang MATLAB>function sigintHandle
<lang MATLAB>function sigintHandle