Advertisement
Guest User

Gérer CTRL+C en Eiffel

a guest
Apr 25th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 0.71 KB | None | 0 0
  1. note
  2.     description: "Montre comment fermer un application avec CTRL+C sans exception."
  3.     autheur: "Louis Marchand"
  4.     date: "Wed, 25 Apr 2018 23:12:33 +0000"
  5.     revision: "0.1"
  6.  
  7. class
  8.     APPLICATION
  9.  
  10. inherit
  11.     EXCEPTIONS
  12.  
  13. create
  14.     make
  15.  
  16. feature {NONE} -- Initialisation
  17.  
  18.     make
  19.             -- Exécute l'application.
  20.         local
  21.             l_ctrl_c:BOOLEAN
  22.         do
  23.             if not l_ctrl_c then
  24.                 from until False loop
  25.                     io.standard_default.put_string ("Appuyez sur CTRL+C%N")
  26.                     io.input.read_line
  27.                 end
  28.             else
  29.                 io.standard_default.put_string ("%NFermeture...%N")
  30.             end
  31.         rescue
  32.             if attached {OPERATING_SYSTEM_SIGNAL_FAILURE} Exception_manager.last_exception then
  33.                 l_ctrl_c := True
  34.                 retry
  35.             end
  36.         end
  37.  
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement