File: vwaitsignal.tcl

package info (click to toggle)
jimtcl 0.83-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,432 kB
  • sloc: ansic: 207,301; tcl: 5,862; sh: 4,834; cpp: 1,671; makefile: 288
file content (26 lines) | stat: -rw-r--r-- 494 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# In lieu of some proper unit tests, this example
# checks that vwait can be interrupted by handled signals

set f [open "/dev/urandom" r]

set count 0

$f ndelay 1

signal handle SIGALRM

$f readable {
	incr count [string bytelength [read $f 100]]
}


set start [clock millis]

# Even though nothing sets 'done', vwait will return on the signal
alarm 0.5
vwait -signal done

set end [clock millis]
puts "Read $count bytes and received [signal check -clear] after $($end - $start)ms"

$f close