Anonymous user
Determine if only one instance is running: Difference between revisions
Determine if only one instance is running (view source)
Revision as of 17:19, 15 July 2020
, 3 years agoAdded BaCon version.
(Added BaCon version.) |
|||
Line 40:
=={{header|AutoHotkey}}==
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|BaCon}}==
Using advisory locks from libc.
<lang bacon>PRAGMA INCLUDE <sys/file.h>
OPTION DEVICE O_NONBLOCK
OPEN ME$ FOR DEVICE AS me
IF flock(me, LOCK_EX | LOCK_NB) <> 0 THEN
PRINT "I am blocked, exiting..."
END
ENDIF
PRINT "Running this program, doing things..."
SLEEP 5000
CLOSE DEVICE me</lang>
=={{header|Bash Shell}}==
|