Exclusive file lock

This commit is contained in:
MrLetsplay 2022-08-28 20:31:53 +02:00
parent c407afe435
commit b1db9d30cf
3 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,6 @@
{
"files.associations": {
"unistd.h": "c"
"unistd.h": "c",
"mman.h": "c"
}
}

View File

@ -5,6 +5,7 @@
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/errno.h>
#include <sys/file.h>
#include <fcntl.h>
struct sus_File_impl{
@ -21,6 +22,8 @@ sus_File sus_fileOpenInMem(char * fileName, unsigned long parameter) {
int fd = open(fileName, flags, S_IRWXU);
if(fd == -1) return NULL;
flock(fd, LOCK_EX);
struct stat info;
if(stat(fileName, &info)) {
close(fd);