summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kike.c47
m---------liberty0
2 files changed, 1 insertions, 46 deletions
diff --git a/kike.c b/kike.c
index d574ef4..1e65318 100644
--- a/kike.c
+++ b/kike.c
@@ -3784,51 +3784,6 @@ irc_initialize_server_name (struct server_context *ctx, struct error **e)
}
static bool
-lock_pid_file (const char *path, struct error **e)
-{
- // When using XDG_RUNTIME_DIR, the file needs to either have its
- // access time bumped every 6 hours, or have the sticky bit set
- int fd = open (path, O_RDWR | O_CREAT,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH /* 644 */ | S_ISVTX /* sticky */);
- if (fd < 0)
- {
- error_set (e, "can't open `%s': %s", path, strerror (errno));
- return false;
- }
-
- struct flock lock =
- {
- .l_type = F_WRLCK,
- .l_start = 0,
- .l_whence = SEEK_SET,
- .l_len = 0,
- };
- if (fcntl (fd, F_SETLK, &lock))
- {
- error_set (e, "can't lock `%s': %s", path, strerror (errno));
- xclose (fd);
- return false;
- }
-
- struct str pid;
- str_init (&pid);
- str_append_printf (&pid, "%ld", (long) getpid ());
-
- if (ftruncate (fd, 0)
- || write (fd, pid.str, pid.len) != (ssize_t) pid.len)
- {
- error_set (e, "can't write to `%s': %s", path, strerror (errno));
- xclose (fd);
- return false;
- }
- str_free (&pid);
-
- // Intentionally not closing the file descriptor; it must stay alive
- // for the entire life of the application
- return true;
-}
-
-static bool
irc_lock_pid_file (struct server_context *ctx, struct error **e)
{
const char *path = str_map_find (&ctx->config, "pid_file");
@@ -3836,7 +3791,7 @@ irc_lock_pid_file (struct server_context *ctx, struct error **e)
return true;
char *resolved = resolve_filename (path, resolve_relative_runtime_filename);
- bool result = lock_pid_file (resolved, e);
+ bool result = lock_pid_file (resolved, e) != -1;
free (resolved);
return result;
}
diff --git a/liberty b/liberty
-Subproject 8a9a28231bba6334c383dca59f7eccd1e507569
+Subproject f213a76ad494efe150a786b195a744e4b87c5ca