This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Mono.Unix.Native; | |
using System.IO; | |
static bool TryLockProcess(string file_to_lock) | |
{ | |
int pid = Syscall.getpid(); | |
int fd = Syscall.open(file_to_lock, OpenFlags.O_CREAT | OpenFlags.O_RDWR, FilePermissions.DEFFILEMODE); | |
if (fd > 0) { | |
// a write (exclusive) lock | |
Flock wl; |