mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-17 02:41:07 +01:00
Recreate server socket on SIGUSR1, per SF feature request 2792533.
This commit is contained in:
parent
92de1ad6c8
commit
03af7c99b5
6
CHANGES
6
CHANGES
@ -1,3 +1,7 @@
|
||||
16 May 2009
|
||||
|
||||
* Recreate server socket on SIGUSR1, per SF feature request 2792533.
|
||||
|
||||
14 May 2009
|
||||
|
||||
* Keys in status line (p in vi mode, M-y in emacs) to paste the first line
|
||||
@ -1257,7 +1261,7 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.288 2009-05-14 19:36:56 nicm Exp $
|
||||
$Id: CHANGES,v 1.289 2009-05-16 10:02:51 nicm Exp $
|
||||
|
||||
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
|
||||
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms
|
||||
|
2
TODO
2
TODO
@ -87,4 +87,6 @@
|
||||
hardcoded 81 for left-vertical is nasty
|
||||
- test bug sshing from freebsd console (tom iirc?)
|
||||
- document clear-history
|
||||
- document paste in status line
|
||||
- document SIGUSR1 behaviour
|
||||
|
||||
|
46
server.c
46
server.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server.c,v 1.142 2009-05-14 07:58:38 nicm Exp $ */
|
||||
/* $Id: server.c,v 1.143 2009-05-16 10:02:51 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -43,6 +43,7 @@
|
||||
/* Client list. */
|
||||
struct clients clients;
|
||||
|
||||
int server_create_socket(void);
|
||||
int server_main(int);
|
||||
void server_shutdown(void);
|
||||
void server_child_signal(void);
|
||||
@ -124,13 +125,10 @@ server_client_index(struct client *c)
|
||||
int
|
||||
server_start(char *path)
|
||||
{
|
||||
struct sockaddr_un sa;
|
||||
size_t size;
|
||||
mode_t mask;
|
||||
int n, fd, pair[2], mode;
|
||||
char *cause;
|
||||
int retcode, pair[2], srv_fd;
|
||||
char *cause;
|
||||
#ifdef HAVE_SETPROCTITLE
|
||||
char rpathbuf[MAXPATHLEN];
|
||||
char rpathbuf[MAXPATHLEN];
|
||||
#endif
|
||||
|
||||
/* The first client is special and gets a socketpair; create it. */
|
||||
@ -187,6 +185,25 @@ server_start(char *path)
|
||||
setproctitle("server (%s)", rpathbuf);
|
||||
#endif
|
||||
|
||||
srv_fd = server_create_socket();
|
||||
server_create_client(pair[1]);
|
||||
|
||||
retcode = server_main(srv_fd);
|
||||
#ifdef DEBUG
|
||||
xmalloc_report(getpid(), "server");
|
||||
#endif
|
||||
exit(retcode);
|
||||
}
|
||||
|
||||
/* Create server socket. */
|
||||
int
|
||||
server_create_socket(void)
|
||||
{
|
||||
struct sockaddr_un sa;
|
||||
size_t size;
|
||||
mode_t mask;
|
||||
int fd, mode;
|
||||
|
||||
memset(&sa, 0, sizeof sa);
|
||||
sa.sun_family = AF_UNIX;
|
||||
size = strlcpy(sa.sun_path, socket_path, sizeof sa.sun_path);
|
||||
@ -214,13 +231,7 @@ server_start(char *path)
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
|
||||
fatal("fcntl failed");
|
||||
|
||||
server_create_client(pair[1]);
|
||||
|
||||
n = server_main(fd);
|
||||
#ifdef DEBUG
|
||||
xmalloc_report(getpid(), "server");
|
||||
#endif
|
||||
exit(n);
|
||||
return (fd);
|
||||
}
|
||||
|
||||
/* Main server loop. */
|
||||
@ -249,6 +260,13 @@ server_main(int srv_fd)
|
||||
sigchld = 0;
|
||||
}
|
||||
|
||||
/* Recreate socket on SIGUSR1. */
|
||||
if (sigusr1) {
|
||||
close(srv_fd);
|
||||
srv_fd = server_create_socket();
|
||||
sigusr1 = 0;
|
||||
}
|
||||
|
||||
/* Initialise pollfd array. */
|
||||
nfds = 1;
|
||||
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
||||
|
18
tmux.c
18
tmux.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.c,v 1.116 2009-05-13 23:27:00 nicm Exp $ */
|
||||
/* $Id: tmux.c,v 1.117 2009-05-16 10:02:51 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -47,6 +47,8 @@ volatile sig_atomic_t sigwinch;
|
||||
volatile sig_atomic_t sigterm;
|
||||
volatile sig_atomic_t sigcont;
|
||||
volatile sig_atomic_t sigchld;
|
||||
volatile sig_atomic_t sigusr1;
|
||||
volatile sig_atomic_t sigusr2;
|
||||
|
||||
char *cfg_file;
|
||||
struct options global_options;
|
||||
@ -110,6 +112,12 @@ sighandler(int sig)
|
||||
case SIGCONT:
|
||||
sigcont = 1;
|
||||
break;
|
||||
case SIGUSR1:
|
||||
sigusr1 = 1;
|
||||
break;
|
||||
case SIGUSR2:
|
||||
sigusr2 = 1;
|
||||
break;
|
||||
}
|
||||
errno = saved_errno;
|
||||
}
|
||||
@ -126,10 +134,6 @@ siginit(void)
|
||||
act.sa_handler = SIG_IGN;
|
||||
if (sigaction(SIGPIPE, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGUSR1, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGUSR2, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGINT, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGTSTP, &act, NULL) != 0)
|
||||
@ -144,6 +148,10 @@ siginit(void)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGCHLD, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGUSR1, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
if (sigaction(SIGUSR2, &act, NULL) != 0)
|
||||
fatal("sigaction failed");
|
||||
}
|
||||
|
||||
void
|
||||
|
4
tmux.h
4
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.316 2009-05-14 19:36:56 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.317 2009-05-16 10:02:51 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -1060,6 +1060,8 @@ extern volatile sig_atomic_t sigwinch;
|
||||
extern volatile sig_atomic_t sigterm;
|
||||
extern volatile sig_atomic_t sigcont;
|
||||
extern volatile sig_atomic_t sigchld;
|
||||
extern volatile sig_atomic_t sigusr1;
|
||||
extern volatile sig_atomic_t sigusr2;
|
||||
extern struct options global_options;
|
||||
extern struct options global_window_options;
|
||||
extern char *cfg_file;
|
||||
|
Loading…
Reference in New Issue
Block a user