first commit
This commit is contained in:
17
src/lock.c
Normal file
17
src/lock.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include "lock.h"
|
||||
#include "paths.h"
|
||||
#include "util.h"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
lock_st lock() {
|
||||
if (exists(mc_lock_path))
|
||||
return ALREADY_LOCKED;
|
||||
if (creat(mc_lock_path, 0600) == -1)
|
||||
return LOCK_ERROR;
|
||||
return LOCK_SUCCESS;
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
unlink(mc_lock_path);
|
||||
}
|
Reference in New Issue
Block a user