mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Do not attempt to connect to the socket as a client if systemd is active, from
Julien Moutinho in GitHub issue 3345.
This commit is contained in:
		
							
								
								
									
										6
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								client.c
									
									
									
									
									
								
							@@ -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);
 | 
						log_debug("flags are %#llx", (unsigned long long)client_flags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Initialize the client socket and start the server. */
 | 
						/* 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);
 | 
						fd = client_connect(base, socket_path, client_flags);
 | 
				
			||||||
	if (fd == -1) {
 | 
						if (fd == -1) {
 | 
				
			||||||
		if (errno == ECONNREFUSED) {
 | 
							if (errno == ECONNREFUSED) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								compat.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								compat.h
									
									
									
									
									
								
							@@ -423,6 +423,7 @@ void		*recallocarray(void *, size_t, size_t, size_t);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_SYSTEMD
 | 
					#ifdef HAVE_SYSTEMD
 | 
				
			||||||
/* systemd.c */
 | 
					/* systemd.c */
 | 
				
			||||||
 | 
					int		 systemd_activated(void);
 | 
				
			||||||
int		 systemd_create_socket(int, char **);
 | 
					int		 systemd_create_socket(int, char **);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,6 +25,12 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					systemd_activated(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return (sd_listen_fds(0) >= 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int
 | 
					int
 | 
				
			||||||
systemd_create_socket(int flags, char **cause)
 | 
					systemd_create_socket(int flags, char **cause)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user