diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-01-17 04:43:43 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-01-17 04:43:43 +0100 |
commit | 6db40c450399f215b1abdb42d5d1d6dee58debb4 (patch) | |
tree | 0c8d2918f5ce261297e6aadab641f30a47c97322 /kike.c | |
parent | f070523085fa88ec25b4276f2024802ce8404fde (diff) | |
download | xK-6db40c450399f215b1abdb42d5d1d6dee58debb4.tar.gz xK-6db40c450399f215b1abdb42d5d1d6dee58debb4.tar.xz xK-6db40c450399f215b1abdb42d5d1d6dee58debb4.zip |
Bump liberty
Diffstat (limited to 'kike.c')
-rw-r--r-- | kike.c | 47 |
1 files changed, 1 insertions, 46 deletions
@@ -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; } |