Files
eiffel-org/documentation/18.01/eiffel/Tutorials/Mini-HowTo/Managing-CTRL-C-on-console.wiki
2018-04-30 00:01:07 +00:00

47 lines
1.2 KiB
Plaintext

[[Property:uuid|5CA34C5D-30F1-4D6F-9FE4-B555E541EA8C]]
[[Property:weight|0]]
[[Property:title|Managing CTRL+C on console]]
[[Property:link_title|CTRL_C terminal]]
Normally, if the user use the CTRL+C keys, the Eiffel application detect it as an error and throw an exception of type <code>{OPERATING_SYSTEM_SIGNAL_FAILURE}</code>. To manage the CTRL+C keys, you can use a <code>rescue</code> clause to detect the exception and a <code>retry</code> mecanism to cancel the exception handeling done by the Eiffel runtime.
<code>
note
description: "Show hot to quit an application using CTRL+C (without trace)."
autheur: "Louis Marchand"
date: "Wed, 25 Apr 2018 23:12:33 +0000"
revision: "0.1"
class
APPLICATION
inherit
EXCEPTIONS
create
make
feature {NONE} -- Initialisation
make
-- Exécute l'application.
local
l_ctrl_c:BOOLEAN
do
if not l_ctrl_c then
from until False loop
io.standard_default.put_string ("Appuyez sur CTRL+C%N")
io.input.read_line
end
else
io.standard_default.put_string ("%NFermeture...%N")
end
rescue
if attached {OPERATING_SYSTEM_SIGNAL_FAILURE}
Exception_manager.last_exception then
l_ctrl_c := True
retry
end
end
end
</code>