18 lines
318 B
C
18 lines
318 B
C
#include "lock.h"
|
|
#include "paths.h"
|
|
#include "util.h"
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
|
|
lock_st lock(char *lock_path) {
|
|
if (exists(lock_path))
|
|
return ALREADY_LOCKED;
|
|
if (creat(lock_path, 0600) == -1)
|
|
return LOCK_ERROR;
|
|
return LOCK_SUCCESS;
|
|
}
|
|
|
|
void unlock(char *lock_path) {
|
|
unlink(lock_path);
|
|
}
|