Determine if only one instance is running: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(One intermediate revision by one other user not shown)
Line 4:
 
=={{header|Ada}}==
 
The following solution tries to open a file for reading. If the file does ''not'' exist, a 'Name_Error' is raised. The exception handler creates that file, allows the program to perform its task, and, eventually, makes sure the file is deleted. If no exception is raised, the file exists, so another instance is running, and the program stops. It also stops if the wrong exception is raised, i.e., any exception other than 'Name_Error'.
 
Line 41 ⟶ 40:
AutoHotkey has a #SingleInstance command. If you run two scripts that don't have it at the same time, it alerts the user. #SingleInstance FORCE closes the older instance when a newer one is run, and #SingleInstance IGNORE does nothing when you try to open a new instance of an already-running script.
 
=={{header|BaConBASIC}}==
==={{header|BaCon}}===
Using advisory locks from libc.
<syntaxhighlight lang="bacon">PRAGMA INCLUDE <sys/file.h>
Line 1,383:
 
Otherwise, the script completes normally and the special file is deleted just before it exits.
<syntaxhighlight lang="ecmascriptwren">import "io" for File, FileFlags
 
var specialFile = "wren-exclusive._sp"
9,476

edits