Determine if only one instance is running: Difference between revisions

m
BaCon moved to the BASIC section.
m (syntax highlighting fixup automation)
m (BaCon moved to the BASIC section.)
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>
511

edits