mirror of
https://github.com/hufrea/byedpi.git
synced 2025-01-19 09:11:53 +00:00
parent
7b46e5958f
commit
1d85d015c2
10
main.c
10
main.c
@ -18,9 +18,6 @@
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifndef F_TLOCK
|
||||
#define lockf(x, y, z) 0
|
||||
#endif
|
||||
#define DAEMON
|
||||
#else
|
||||
#include <ws2tcpip.h>
|
||||
@ -546,7 +543,11 @@ int init_pid_file(const char *fname)
|
||||
if (params.pid_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (lockf(params.pid_fd, F_TLOCK, 0) < 0) {
|
||||
struct flock fl = {
|
||||
.l_whence = SEEK_CUR,
|
||||
.l_type = F_WRLCK
|
||||
};
|
||||
if (fcntl(params.pid_fd, F_SETLK, &fl) < 0) {
|
||||
return -1;
|
||||
}
|
||||
params.pid_file = fname;
|
||||
@ -566,7 +567,6 @@ void clear_params(void)
|
||||
#endif
|
||||
#ifdef DAEMON
|
||||
if (params.pid_fd > 0) {
|
||||
lockf(params.pid_fd, F_ULOCK, 0);
|
||||
close(params.pid_fd);
|
||||
}
|
||||
if (params.pid_file) {
|
||||
|
Loading…
Reference in New Issue
Block a user