cours0708/P5B/ruby/161007/testSig_1.rb
2008-11-25 22:11:16 +01:00

18 lines
338 B
Ruby

#!/usr/bin/ruby -w
nsec=0
trap("SIGINT" ){ #attention a la place de la parenthese ouvrante
puts "\n"+nsec.to_s + " secondes ecoulees \n"
}
trap("SIGQUIT" ){ #attention a la place de la parenthese ouvrante
puts "\nFin du chronomètre "+nsec.to_s + " secondes ecoulees \n"
exit
}
while true
sleep 1
nsec = nsec + 1
end