Handle a signal: Difference between revisions

Add BaCon
m (→‎{{header|REXX}}: added a comment to the output showing where and when the user pressed the Crtl-C buttons.)
(Add BaCon)
Line 148:
6
Task took 3.526 Seconds</pre>
 
=={{header|BaCon}}==
<lang freebasic>' Handle signal
SUB Finished
SIGNAL SIG_DFL, SIGINT : ' Restore SIGINT to default
PRINT "Running for", TIMER / 1000.0, "seconds" FORMAT "%s %f %s\n"
STOP SIGINT : ' Send another terminating SIGINT
ENDSUB
 
SIGNAL Finished, SIGINT
iter = 1
passed = TIMER
WHILE TRUE
IF TIMER > passed + 500 THEN
PRINT iter
passed = TIMER
iter = iter + 1
ENDIF
WEND</lang>
 
{{out}}
<pre>$ ./handle-signal
1
2
3
^CRunning for 1.766000 seconds</pre>
 
=={{header|BBC BASIC}}==
Anonymous user