summaryrefslogtreecommitdiffstats
path: root/tclsignal/tests/test_sig_async.tk
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-01-02 19:05:44 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-01-02 19:05:44 (GMT)
commit482241bea02f1e740f0a4f4fcf5b9ea29f1f678a (patch)
treebadcbd8eaa03d1688fea1a4ad269e932aa2996f1 /tclsignal/tests/test_sig_async.tk
parent3cd540c3f22f5d85dffae5542cf58f8855f7b847 (diff)
parentfe3a889e527a0369c6f7d42675f358815143a502 (diff)
downloadblt-482241bea02f1e740f0a4f4fcf5b9ea29f1f678a.zip
blt-482241bea02f1e740f0a4f4fcf5b9ea29f1f678a.tar.gz
blt-482241bea02f1e740f0a4f4fcf5b9ea29f1f678a.tar.bz2
Merge commit 'fe3a889e527a0369c6f7d42675f358815143a502' as 'tclsignal'
Diffstat (limited to 'tclsignal/tests/test_sig_async.tk')
-rwxr-xr-xtclsignal/tests/test_sig_async.tk50
1 files changed, 50 insertions, 0 deletions
diff --git a/tclsignal/tests/test_sig_async.tk b/tclsignal/tests/test_sig_async.tk
new file mode 100755
index 0000000..24ac543
--- /dev/null
+++ b/tclsignal/tests/test_sig_async.tk
@@ -0,0 +1,50 @@
+#!/usr/local/bin/wish4.1
+# ENSURE YOUR TCLLIBPATH includes /usr/local/lib/signal!
+# (or uncomment the appropriate load line and comment the package line)
+# --SUN
+# load /usr/local/lib/signal_ext.so
+# --HP
+# load /usr/local/lib/signal_ext.sl
+
+# Proc to do something absurd for a long time
+proc do_long_job { } {
+ for { set i 0 } { $i < 300000 } { incr i } { expr $i * $i }
+}
+
+package require Signal
+
+signal add 21 { wm iconify . ; wm deiconify . }
+signal add SIGHUP { puts "Signal 1 received" }
+signal add SIGINT { puts "SIGINT received" ; error "SIGINT interrupt" } -async
+signal add SIGQUIT { puts "SIGQUIT received" } -async
+
+puts "Showing all the signals handled"
+puts [signal print]
+puts "Showing how 3 is handled"
+puts [signal print 3]
+puts "Showing how SIGTTOU is handled"
+puts [signal print SIGTTOU]
+
+frame .bottom
+button .bottom.b -text "Done" -command "exit 0"
+button .bottom.j -text "Long Job" -command do_long_job
+button .bottom.i -text "Iconify" -command "wm iconify ."
+label .l -wraplength 60m -justify l -text {
+Sending this process SIGHUP will (eventually) result in a message;
+
+SIGQUIT (^\) will result in a message immediately.
+
+SIGINT (^C) will result in an error trace immediately. This is the result of the -async option on signal handlers
+
+Signal 21 (URG) will pop the dialog up!
+
+Pressing the "Long Job" button will perform a single, long calculation where no buttons presses will have immediate effect, but SIGINT will interrupt the calculation prematurely
+}
+
+pack .bottom.b -side left -fill x
+pack .bottom.j -side left -fill x
+pack .bottom.i -side right -fill x
+pack .l -side top -fill both -expand true
+pack .bottom -in . -side bottom -fill x
+
+update