diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2022-10-18 15:58:06 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2022-10-18 15:58:06 +0100 |
commit | 5ce34add77fa3517a01e63b915c5f4e3241af470 (patch) | |
tree | ee5e13606e15ad4d8c2154e3334c8b2711dc34f8 | |
parent | 934f357149dba903f091237e7ea7c7ba78471614 (diff) | |
download | rtmux-5ce34add77fa3517a01e63b915c5f4e3241af470.tar.gz rtmux-5ce34add77fa3517a01e63b915c5f4e3241af470.tar.bz2 rtmux-5ce34add77fa3517a01e63b915c5f4e3241af470.zip |
Do not attempt to connect to the socket as a client if systemd is active, from
Julien Moutinho in GitHub issue 3345.
-rw-r--r-- | client.c | 6 | ||||
-rw-r--r-- | compat.h | 1 | ||||
-rw-r--r-- | compat/systemd.c | 6 |
3 files changed, 13 insertions, 0 deletions
@@ -284,6 +284,12 @@ client_main(struct event_base *base, int argc, char **argv, uint64_t flags, log_debug("flags are %#llx", (unsigned long long)client_flags); /* Initialize the client socket and start the server. */ +#ifdef HAVE_SYSTEMD + if (systemd_activated()) { + /* socket-based activation, do not even try to be a client. */ + fd = server_start(client_proc, flags, base, 0, NULL); + } else +#endif fd = client_connect(base, socket_path, client_flags); if (fd == -1) { if (errno == ECONNREFUSED) { @@ -423,6 +423,7 @@ void *recallocarray(void *, size_t, size_t, size_t); #ifdef HAVE_SYSTEMD /* systemd.c */ +int systemd_activated(void); int systemd_create_socket(int, char **); #endif diff --git a/compat/systemd.c b/compat/systemd.c index 9a3adbb3..cce42ed4 100644 --- a/compat/systemd.c +++ b/compat/systemd.c @@ -26,6 +26,12 @@ #include "tmux.h" int +systemd_activated(void) +{ + return (sd_listen_fds(0) >= 1); +} + +int systemd_create_socket(int flags, char **cause) { int fds; |