aboutsummaryrefslogtreecommitdiff
path: root/examples/tip.tcl
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2016-10-19 07:51:46 +1000
committerSteve Bennett <steveb@workware.net.au>2016-10-19 07:51:46 +1000
commitb464e52b99e0a44d8a0fae616b193bd2250e209b (patch)
treec5943775c942a432378e9920cd4101bdd0cef118 /examples/tip.tcl
parent8503e9e27495141813a325a6cc770d3550c889c3 (diff)
downloadjimtcl-b464e52b99e0a44d8a0fae616b193bd2250e209b.zip
jimtcl-b464e52b99e0a44d8a0fae616b193bd2250e209b.tar.gz
jimtcl-b464e52b99e0a44d8a0fae616b193bd2250e209b.tar.bz2
examples/tip.tcl: Lock the device
Prevent multiple access to a serial port by using locking. This is probably compatible with most serial port locking on Linux. Perhaps on macosx. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'examples/tip.tcl')
-rwxr-xr-xexamples/tip.tcl5
1 files changed, 5 insertions, 0 deletions
diff --git a/examples/tip.tcl b/examples/tip.tcl
index 2770dcb..3de25e3 100755
--- a/examples/tip.tcl
+++ b/examples/tip.tcl
@@ -82,6 +82,11 @@ try {
return 1
}
+if {[$f lock] == 0} {
+ puts "Device is in use: $device"
+ return 1
+}
+
try {
$f tty {*}$settings
} on error msg {