Is there a way to share a lock (e.g. a lock file) between R processes?
locking, r, semaphore
Solution
While I couldn't find an R package, there is the Linux command `lockfile` that can be used:
write("Attempting to get lock", stderr())
system("lockfile /tmp/my_simple_lock")
# Do stuff
write("Releasing lock", stderr())
system("rm -f /tmp/my_simple_lock")
Problem
I have a bunch of different R processes (independently launched from the command line) that all need to load different big files. To avoid clogging the network, I want to add a lock / semaphore, e.g. via a lock file, so that they get their file one after the other. Only one process should be able to acquire the lock, on a standard Linux system.