Anonymous user
Determine if only one instance is running: Difference between revisions
Determine if only one instance is running (view source)
Revision as of 08:18, 7 July 2009
, 14 years ago→{{header|Tcl}}: Added code to pick a port number magically
m (→Linux (including cygwin) and Mac OSX Leopard: formatting) |
(→{{header|Tcl}}: Added code to pick a port number magically) |
||
Line 143:
{{trans|Java}} <br>
{{works with|Tcl|8.6}}
<lang Tcl>
try {
# Pick a port number based on the name of the main script executing
[expr {1024+[zlib crc32 [file normalize $::argv0]]%30000}]
} trap {POSIX EADDRINUSE} {} {
# Generate a nice error message
puts stderr "Application $::argv0 already running?"
exit 1
}</lang>
|